Skip to content

weird const_missing exceptions in mrblib code (mruby 3.1.0 and above) #5725

@kazuho

Description

@kazuho

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:

  1. Checkout mruby 3.0 support iij/mruby-require#29.
  2. Build mruby with the following configuration:
MRuby::Build.new do |conf|
  conf.toolchain :gcc
  conf.gembox "default"
  conf.gem "mruby-require"
end
  1. 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_method and 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions