Skip to content

require_relative doesn't work inside Jar with 9.3.4.0 #7211

@dgolombek

Description

@dgolombek

Environment Information

Provide at least:

  • JRuby version (jruby -v) and command line (flags, JRUBY_OPTS, etc)
    jruby 9.3.4.0 (2.6.8) 2022-03-23 eff48c1 OpenJDK 64-Bit Server VM 25.232-b09 on 1.8.0_232-b09 +jit [x86_64-darwin]
  • Operating system and platform (e.g. uname -a)
    Darwin ip-192-168-1-155.us-west-2.compute.internal 18.7.0 Darwin Kernel Version 18.7.0: Tue Jan 12 22:04:47 PST 2021; root:xnu-4903.278.56~1/RELEASE_X86_64 x86_64
    (But also reproduces in Docker with Ubuntu 18.04)

Other relevant info you may wish to add:
See https://github.com/dgolombek/loadpath_bug for code to reproduce

Expected Behavior
When compiled with JRuby 9.2.9.0 embedded, this works correctly. I see

["uri:classloader://loadpath_bug/lib", "/Users/david.golombek/.rvm/gems/ruby-2.6.3@global/gems/did_you_mean-1.3.0/lib", "uri:classloader:/gems/bundler-2.3.13/lib", "uri:classloader:/META-INF/jruby.home/lib/ruby/2.5/site_ruby", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib"]
In loadpath-bug.rb before require
In loadpath-bug.rb after require
In loadpath-bug.rb before require_relative
In loadpath-bug.rb after require_relative
Starting!

Actual Behavior

With 9.3.4.0, I see

["uri:classloader:/loadpath_bug/lib", "/Users/david.golombek/.rvm/rubies/ruby-2.6.3/lib/ruby/gems/2.6.0/gems/did_you_mean-1.3.0/lib", "uri:classloader:/gems/bundler-2.3.13/lib", "uri:classloader:/META-INF/jruby.home/lib/ruby/2.6/site_ruby", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib"]
In loadpath-bug.rb before require
In loadpath-bug.rb after require
In loadpath-bug.rb before require_relative
ERROR: org.jruby.embed.EvalFailedException: (ENOENT) No such file or directory - /private/tmp/lib/loadpath/bug.rb

As you can see, the require works, but require_relative doesn't. And it doesn't seem to be related to both bug.rb and bug/ existing -- this fails when name and directory aren't the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions