berkesokhan / rubydotnetcompiler

Automatically exported from code.google.com/p/rubydotnetcompiler
1 stars 0 forks source link

Lost LoadError Exception #22

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

I'm working towards getting ERB working. There is a problem with the 
reporting of load errors on 'require'. ERB requires 'strscan', which is 
not available yet of course. The expected output is:

Unhandled Exception: ... : No such file to load -- strscan

However this is what I get:
Unhandled Exception: Ruby.Runtime.RubyException: undefined local variable 
or method `n1' for Module
   at Ruby.Compiler.AST.SOURCEFILE.ExecuteMain(Assembly Assembly, String[] 
args)
   at Ruby.Compiler.AST.SOURCEFILE.ExecuteMain(PEFile Assembly, String[] 
args)
   at Ruby.Compiler.RubyEntry.Process(String[] args)
   at RubyMain.Main(String[] args) in Ruby\Main.cs:line 5

In the debugger I can see line 456 in eval.cs getting executed and 
constructing the LoadError, but the method does not seem to do the throw 
correctly as the code continues. If I change the code to this it works:
  if (path == null)
    throw new System.ApplicationException("No such file to load -- " + 
((String)fname).value);

The code works fine in any other mockup that I try so I can't pin it down 
better at the moment. It's not simply a case of nested requires, or 
requires within a class definition.

What version of the product are you using? On what operating system?
Rev 86. windows XP

Please provide any additional information below.

Original issue reported on code.google.com by djl_davi...@rifraf.net on 11 Sep 2007 at 1:31

GoogleCodeExporter commented 9 years ago
I downloaded the ERB module and certainly encountered some problems related to 
the 
Buffer class colliding with the System.Buffer class in mscorlib. I'm working on 
that 
problem, but I was unable to reproduce your original problem. When I tried a 
simple 
test program containing:

require 'strscan'

I obtained:

Unhandled Exception: Ruby.Runtime.RubyException: No such file to load -- strscan
   at Ruby.Compiler.AST.SOURCEFILE.ExecuteMain(Assembly Assembly, String[] args)
   at Ruby.Compiler.AST.SOURCEFILE.ExecuteMain(PEFile Assembly, String[] args)
   at Ruby.Compiler.RubyEntry.Process(String[] args)
   at RubyMain.Main(String[] args) in C:\Ruby.NET2\src\Ruby\Main.cs:line 5

as you expected.

Could you please provide a more detailed explanation of how you produced the 
error 
you did? Did you use Ruby.exe or RubyCompiler.exe? What was your current 
directory? 
Exactly what command line arguments did you use?

Original comment by DrWayneK...@gmail.com on 19 Sep 2007 at 5:05

GoogleCodeExporter commented 9 years ago
Thanks for looking into this. The issue is with Ruby.exe when I run it either 
directly from within 'bin' or through the VS debugger. As I said, if I write 
some 
code that just does a require on strscan then the message is fine. It is only 
where 
the require is done within ERB that the message gets lost on its way back and I 
get 
the message 
Unhandled Exception: Ruby.Runtime.RubyException: undefined local variable or met
hod `n1' for Module at Ruby.Compiler.AST.SOURCEFILE.ExecuteMain(Assembly 
Assembly, 
String[] args)
   at Ruby.Compiler.AST.SOURCEFILE.ExecuteMain(PEFile Assembly, String[] args)
   at Ruby.Compiler.RubyEntry.Process(String[] args)
   at RubyMain.Main(String[] args) in H:\Play\Ruby.Net\trunk\src\Ruby\Main.cs:li
ne 5

In the debugger I can see the 'throw new LoadError' firing, but I've not been 
able 
to trace back to see what is catching the LoadError. If I change the throw to 
send a 
System.ApplicationException then the error does percolate to the top level.

I've attached my test file 'hi.rb'.

I just did an SVN update to see if the problem has move on since the original 
report, but I now get Unhandled Exception: System.TypeInitializationException: 
The 
type initializer fo
r 'Ruby.Compiler.CodeGenContext' threw an exception. ---> System.TypeInitializat
ionException: The type initializer for 'Ruby.Compiler.Runtime' threw an exceptio
n. ---> System.MissingMethodException: Method not found: 'PERWAPI.AssemblyRef PE
RWAPI.AssemblyRef.MakeAssemblyRef(System.String, UInt16, UInt16, UInt16, UInt16,
 Byte[])'.
   at Ruby.Compiler.Runtime..cctor()
and lunchtime is over...!!!

Regards

Original comment by djl_davi...@rifraf.net on 20 Sep 2007 at 12:26

GoogleCodeExporter commented 9 years ago
2nd attempt at attachment

Original comment by djl_davi...@rifraf.net on 20 Sep 2007 at 12:27

Attachments:

GoogleCodeExporter commented 9 years ago
The PERWAPI issue has gone away now that I have dragged the DLLs into the GAC 
manually thanks.

I have put hi.rb into 'bin' (i.e. alongside test.rb) and I run it using the 
command 
line 'Ruby.exe hi.rb'. The standard erb implementation is off in some other 
path - 
hence the gash code in hi.rb that adds to $LOAD_PATH

I have run 'Ruby.exe test.rb' and that works fine.

Original comment by djl_davi...@rifraf.net on 21 Sep 2007 at 11:37

GoogleCodeExporter commented 9 years ago
Just to confirm, is the original problem gone now?

(The bug with Buffer might be the same as issue #30.)

Original comment by sason...@gmail.com on 27 Sep 2007 at 6:39

GoogleCodeExporter commented 9 years ago
No - the original problem is still there on my machine.

Curiously I don't get any clash with Buffer. Maybe a different ERB? My one is 
attached.

Original comment by djl_davi...@rifraf.net on 27 Sep 2007 at 12:11

Attachments:

GoogleCodeExporter commented 9 years ago
No - the original problem is still there on my machine.

Curiously I don't get any clash with Buffer. Maybe a different ERB? My one is 
attached.

Original comment by djl_davi...@rifraf.net on 27 Sep 2007 at 12:12

Attachments:

GoogleCodeExporter commented 9 years ago
Er... this would be the cause:

  begin # line 406
    require 'strscan'
    # ...
  rescue LoadError # line 485
  end

Original comment by sason...@gmail.com on 27 Sep 2007 at 12:33

GoogleCodeExporter commented 9 years ago
Awww... shucks!! No wonder I couldn't find a catch in the .Net code, it was in 
ERB 
all along. One up for Ruby.Net. 

It's interesting that my assumption was that there must be an issue in the 
'new' 
code, rather than also checking out the 'old but must be working' code in ERB 
itself.

As a penance, how about if I supply you with a version of strscan so that (a) 
this 
issue goes away and (b) I get to have a working copy of ERB under .net??

Original comment by djl_davi...@rifraf.net on 28 Sep 2007 at 12:33

GoogleCodeExporter commented 9 years ago
I haven't looked at Rubinius' strscan, but you can probably just use what they 
have.

Closing this bug..

Original comment by sason...@gmail.com on 1 Oct 2007 at 1:25