mattn/mruby-require

Attempting require on .mrb file causes crash

expeditiousRubyist opened this issue · 8 comments

Tested on Windows, and built with mingw-w64 5.1

Using require from either mirb or a script ran with mruby will work fine for a standard .rb script, but attempting to load .mrb bytecode compiled from that same script causes an immediate crash.

mattn commented

could you please show me the way to reproduce?

Compiled mruby with mruby-require from the latest sources
Created a file test.rb with a module Foo with only one function called "hello" that prints its argument.
Compiled test.rb to test.mrb using mrbc
Renamed test.rb to hello.rb to ensure require would load the .mrb file instead of the .rb file (I don't know if this is actually necessary)
Ran ./mirb
First line tested in the REPL was require "./test"
Program crashes with something to the tune of "mirb.exe has stopped working"

My build environment is Windows 8.1 64-bit, using Git Bash as a shell, and MinGW-w64 as my C compiler.

mattn commented

Currently, mruby-require doesn't support ./.

mattn commented

could you try to use load "./test" instead.

Same issue with using load instead of require. Also, it works fine when loading regular .rb files using relative paths. Why would a relative path (i.e. require "test" vs require "./test") be a cause for failure? Especially when require "test" does not seem to look in the current directory for files.

And for some reason I have stopped receiving this error despite the source of mruby-require not changing. Perhaps the error was in mruby itself, which has thus been fixed?

mattn commented

I'm not sure. Sorry.