I've been trying to use mruby-require with the recent versions of mruby (see iij/mruby-require#29) and have noticed one behavior that seems like an issue with mruby 3.1.0 and above.
When I run mruby-require of the PR linked above with mruby 3.0.0, everything works fine. But when I run it using mruby 3.1.0, a const_missing error is raised complaining that File.exist? cannot be found.
Steps to reproduce:
- Checkout mruby 3.0 support iij/mruby-require#29.
- Build mruby with the following configuration:
MRuby::Build.new do |conf| conf.toolchain :gcc conf.gembox "default" conf.gem "mruby-require" end
- Run the following script using mruby being built:
print "#{File.file?("/")}\n" require "/nonexistent"
When I run this script using mruby 3.0.0 being built, the first line emits "false" (because / is a directory), then complains that /nonexistent cannot be loaded. Fine.
But when I run this script using mruby 3.1.0 being built, it raises a const_missing exception here.
Why I think this is a bug of mruby:
While this error is related to mruby-require, I'm reporting it here because I suspect this is a problem of mruby, due to the following reasons:
- the version of mruby-require being used does not have external dependency outside of mrbgems bundled by mruby
- the "gem_init" function of mruby-require just calls
mrb_define_methodand does nothing else, the problem that we see seems to happen before any logic of mruby-require written in C is being invoked
Therefore, I'm suspecting if there's an issue with the ruby code found in mrbgems having issues with accessing constants defined in other mrbgems.