Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add uri:classloader://META-INF/jruby.home/lib/ruby/gems/shared to GEM_PATH #301

Open
mkristian opened this issue Jan 9, 2015 · 5 comments

Comments

@mkristian
Copy link
Member

mkristian commented Jan 9, 2015

adding uri:classloader://META-INF/jruby.home/lib/ruby/gems/shared will ensure the default gems from jruby are treated as default gems with ALL classloaders.

in case the uri:classloader protocol is unknown to jruby (1.7.13 and before), it will add a slightly extra failed places before reporting a missing file.

the current situation with "exotic" classloaders is to set classpath://META-INF/jruby.home/lib/ruby/gems/shared which does not find the default gems from jruby.

not sure if this or where this is possible to add something to the GEM_PATH or to Gem::Specification.dirs

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/7624613-add-uri-classloader-meta-inf-jruby-home-lib-ruby-gems-shared-to-gem_path?utm_campaign=plugin&utm_content=tracker%2F136961&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F136961&utm_medium=issues&utm_source=github).
@mkristian mkristian changed the title add uri:classloader://META-INF/jruby.home/lib/ruby/gems/shared to $LOAD_PATH add uri:classloader://META-INF/jruby.home/lib/ruby/gems/shared to GEM_PATH Jan 9, 2015
@jkutner
Copy link
Member

jkutner commented May 13, 2015

This is fixed in 2.x-dev

@jkutner
Copy link
Member

jkutner commented May 13, 2015

eh, might not be fixed in all places. i'll double check that

@jgwmaxwell
Copy link

Can I ask - would this bug manifest in the following way? (with -Djruby.debug.loadService enabled)

2015-05-15T14:35:51.179Z: LoadService: trying builtinLib: logger.rb
2015-05-15T14:35:51.179Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/virtus-1.0.5/lib/logger.rb
2015-05-15T14:35:51.180Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/frenzy_bunnies-0.0.8/lib/logger.rb
2015-05-15T14:35:51.180Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/thor-0.19.1/lib/logger.rb
2015-05-15T14:35:51.180Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/sinatra-1.4.6/lib/logger.rb
2015-05-15T14:35:51.180Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/tilt-2.0.1/lib/logger.rb
2015-05-15T14:35:51.181Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/rack-protection-1.5.3/lib/logger.rb
2015-05-15T14:35:51.181Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/rack-1.6.1/lib/logger.rb
2015-05-15T14:35:51.181Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/march_hare-2.10.0.pre-java/lib/logger.rb
2015-05-15T14:35:51.181Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/equalizer-0.0.11/lib/logger.rb
2015-05-15T14:35:51.182Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/coercible-1.0.0/lib/logger.rb
2015-05-15T14:35:51.182Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/bugsnag-2.8.6/lib/logger.rb
2015-05-15T14:35:51.182Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/multi_json-1.11.0/lib/logger.rb
2015-05-15T14:35:51.182Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/axiom-types-0.1.1/lib/logger.rb
2015-05-15T14:35:51.183Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/ice_nine-0.11.1/lib/logger.rb
2015-05-15T14:35:51.183Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/descendants_tracker-0.0.4/lib/logger.rb
2015-05-15T14:35:51.183Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/atomic-1.1.99-java/lib/logger.rb
2015-05-15T14:35:51.183Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/activemodel-4.2.1/lib/logger.rb
2015-05-15T14:35:51.184Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/builder-3.2.2/lib/logger.rb
2015-05-15T14:35:51.184Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/activesupport-4.2.1/lib/logger.rb
2015-05-15T14:35:51.184Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/tzinfo-1.2.2/lib/logger.rb
2015-05-15T14:35:51.184Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/thread_safe-0.3.5-java/lib/logger.rb
2015-05-15T14:35:51.185Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/minitest-5.6.1/lib/logger.rb
2015-05-15T14:35:51.185Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/json-1.8.2-java/lib/logger.rb
2015-05-15T14:35:51.185Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/i18n-0.7.0/lib/logger.rb
2015-05-15T14:35:51.185Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/bundler-1.9.8/lib/logger.rb
2015-05-15T14:35:51.185Z: LoadService: trying fileResource: ./logger.rb
2015-05-15T14:35:51.186Z: LoadService: trying fileResource: uri:classloader://logger.rb
2015-05-15T14:35:51.186Z: LoadService: trying jarExtension: logger
2015-05-15T14:35:51.186Z: LoadService: trying builtinLib: logger.jar
2015-05-15T14:35:51.186Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/virtus-1.0.5/lib/logger.jar
2015-05-15T14:35:51.186Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/frenzy_bunnies-0.0.8/lib/logger.jar
2015-05-15T14:35:51.186Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/thor-0.19.1/lib/logger.jar
2015-05-15T14:35:51.186Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/sinatra-1.4.6/lib/logger.jar
2015-05-15T14:35:51.186Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/tilt-2.0.1/lib/logger.jar
2015-05-15T14:35:51.186Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/rack-protection-1.5.3/lib/logger.jar
2015-05-15T14:35:51.187Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/rack-1.6.1/lib/logger.jar
2015-05-15T14:35:51.187Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/march_hare-2.10.0.pre-java/lib/logger.jar
2015-05-15T14:35:51.187Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/equalizer-0.0.11/lib/logger.jar
2015-05-15T14:35:51.187Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/coercible-1.0.0/lib/logger.jar
2015-05-15T14:35:51.187Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/bugsnag-2.8.6/lib/logger.jar
2015-05-15T14:35:51.187Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/multi_json-1.11.0/lib/logger.jar
2015-05-15T14:35:51.188Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/axiom-types-0.1.1/lib/logger.jar
2015-05-15T14:35:51.188Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/ice_nine-0.11.1/lib/logger.jar
2015-05-15T14:35:51.188Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/descendants_tracker-0.0.4/lib/logger.jar
2015-05-15T14:35:51.188Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/atomic-1.1.99-java/lib/logger.jar
2015-05-15T14:35:51.188Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/activemodel-4.2.1/lib/logger.jar
2015-05-15T14:35:51.188Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/builder-3.2.2/lib/logger.jar
2015-05-15T14:35:51.188Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/activesupport-4.2.1/lib/logger.jar
2015-05-15T14:35:51.188Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/tzinfo-1.2.2/lib/logger.jar
2015-05-15T14:35:51.188Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/thread_safe-0.3.5-java/lib/logger.jar
2015-05-15T14:35:51.188Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/minitest-5.6.1/lib/logger.jar
2015-05-15T14:35:51.189Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/json-1.8.2-java/lib/logger.jar
2015-05-15T14:35:51.189Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/i18n-0.7.0/lib/logger.jar
2015-05-15T14:35:51.189Z: LoadService: trying fileResource: file:/app/blaine.jar!/gems/bundler-1.9.8/lib/logger.jar
2015-05-15T14:35:51.189Z: LoadService: trying fileResource: ./logger.jar
2015-05-15T14:35:51.189Z: LoadService: trying fileResource: uri:classloader://logger.jar
2015-05-15T14:35:51.189Z: LoadService: trying fileInClasspath: gems/virtus-1.0.5/lib/logger.rb
2015-05-15T14:35:51.189Z: LoadService: trying fileInClasspath: gems/frenzy_bunnies-0.0.8/lib/logger.rb
2015-05-15T14:35:51.190Z: LoadService: trying fileInClasspath: gems/thor-0.19.1/lib/logger.rb
2015-05-15T14:35:51.190Z: LoadService: trying fileInClasspath: gems/sinatra-1.4.6/lib/logger.rb
2015-05-15T14:35:51.190Z: LoadService: trying fileInClasspath: gems/tilt-2.0.1/lib/logger.rb
2015-05-15T14:35:51.190Z: LoadService: trying fileInClasspath: gems/rack-protection-1.5.3/lib/logger.rb
2015-05-15T14:35:51.190Z: LoadService: trying fileInClasspath: gems/rack-1.6.1/lib/logger.rb
2015-05-15T14:35:51.190Z: LoadService: trying fileInClasspath: gems/march_hare-2.10.0.pre-java/lib/logger.rb
2015-05-15T14:35:51.190Z: LoadService: trying fileInClasspath: gems/equalizer-0.0.11/lib/logger.rb
2015-05-15T14:35:51.191Z: LoadService: trying fileInClasspath: gems/coercible-1.0.0/lib/logger.rb
2015-05-15T14:35:51.191Z: LoadService: trying fileInClasspath: gems/bugsnag-2.8.6/lib/logger.rb
2015-05-15T14:35:51.191Z: LoadService: trying fileInClasspath: gems/multi_json-1.11.0/lib/logger.rb
2015-05-15T14:35:51.191Z: LoadService: trying fileInClasspath: gems/axiom-types-0.1.1/lib/logger.rb
2015-05-15T14:35:51.191Z: LoadService: trying fileInClasspath: gems/ice_nine-0.11.1/lib/logger.rb
2015-05-15T14:35:51.191Z: LoadService: trying fileInClasspath: gems/descendants_tracker-0.0.4/lib/logger.rb
2015-05-15T14:35:51.191Z: LoadService: trying fileInClasspath: gems/atomic-1.1.99-java/lib/logger.rb
2015-05-15T14:35:51.191Z: LoadService: trying fileInClasspath: gems/activemodel-4.2.1/lib/logger.rb
2015-05-15T14:35:51.191Z: LoadService: trying fileInClasspath: gems/builder-3.2.2/lib/logger.rb
2015-05-15T14:35:51.191Z: LoadService: trying fileInClasspath: gems/activesupport-4.2.1/lib/logger.rb
2015-05-15T14:35:51.192Z: LoadService: trying fileInClasspath: gems/tzinfo-1.2.2/lib/logger.rb
2015-05-15T14:35:51.192Z: LoadService: trying fileInClasspath: gems/thread_safe-0.3.5-java/lib/logger.rb
2015-05-15T14:35:51.192Z: LoadService: trying fileInClasspath: gems/minitest-5.6.1/lib/logger.rb
2015-05-15T14:35:51.192Z: LoadService: trying fileInClasspath: gems/json-1.8.2-java/lib/logger.rb
2015-05-15T14:35:51.192Z: LoadService: trying fileInClasspath: gems/i18n-0.7.0/lib/logger.rb
2015-05-15T14:35:51.192Z: LoadService: trying fileInClasspath: gems/bundler-1.9.8/lib/logger.rb
2015-05-15T14:35:51.192Z: LoadService: trying fileInClasspath: logger.rb
2015-05-15T14:35:51.192Z: LoadService: trying fileInClasspath: gems/virtus-1.0.5/lib/logger.jar
2015-05-15T14:35:51.193Z: LoadService: trying fileInClasspath: gems/frenzy_bunnies-0.0.8/lib/logger.jar
2015-05-15T14:35:51.193Z: LoadService: trying fileInClasspath: gems/thor-0.19.1/lib/logger.jar
2015-05-15T14:35:51.193Z: LoadService: trying fileInClasspath: gems/sinatra-1.4.6/lib/logger.jar
2015-05-15T14:35:51.193Z: LoadService: trying fileInClasspath: gems/tilt-2.0.1/lib/logger.jar
2015-05-15T14:35:51.193Z: LoadService: trying fileInClasspath: gems/rack-protection-1.5.3/lib/logger.jar
2015-05-15T14:35:51.193Z: LoadService: trying fileInClasspath: gems/rack-1.6.1/lib/logger.jar
2015-05-15T14:35:51.193Z: LoadService: trying fileInClasspath: gems/march_hare-2.10.0.pre-java/lib/logger.jar
2015-05-15T14:35:51.193Z: LoadService: trying fileInClasspath: gems/equalizer-0.0.11/lib/logger.jar
2015-05-15T14:35:51.193Z: LoadService: trying fileInClasspath: gems/coercible-1.0.0/lib/logger.jar
2015-05-15T14:35:51.193Z: LoadService: trying fileInClasspath: gems/bugsnag-2.8.6/lib/logger.jar
2015-05-15T14:35:51.194Z: LoadService: trying fileInClasspath: gems/multi_json-1.11.0/lib/logger.jar
2015-05-15T14:35:51.194Z: LoadService: trying fileInClasspath: gems/axiom-types-0.1.1/lib/logger.jar
2015-05-15T14:35:51.194Z: LoadService: trying fileInClasspath: gems/ice_nine-0.11.1/lib/logger.jar
2015-05-15T14:35:51.194Z: LoadService: trying fileInClasspath: gems/descendants_tracker-0.0.4/lib/logger.jar
2015-05-15T14:35:51.194Z: LoadService: trying fileInClasspath: gems/atomic-1.1.99-java/lib/logger.jar
2015-05-15T14:35:51.194Z: LoadService: trying fileInClasspath: gems/activemodel-4.2.1/lib/logger.jar
2015-05-15T14:35:51.194Z: LoadService: trying fileInClasspath: gems/builder-3.2.2/lib/logger.jar
2015-05-15T14:35:51.194Z: LoadService: trying fileInClasspath: gems/activesupport-4.2.1/lib/logger.jar
2015-05-15T14:35:51.195Z: LoadService: trying fileInClasspath: gems/tzinfo-1.2.2/lib/logger.jar
2015-05-15T14:35:51.195Z: LoadService: trying fileInClasspath: gems/thread_safe-0.3.5-java/lib/logger.jar
2015-05-15T14:35:51.195Z: LoadService: trying fileInClasspath: gems/minitest-5.6.1/lib/logger.jar
2015-05-15T14:35:51.195Z: LoadService: trying fileInClasspath: gems/json-1.8.2-java/lib/logger.jar
2015-05-15T14:35:51.195Z: LoadService: trying fileInClasspath: gems/i18n-0.7.0/lib/logger.jar
2015-05-15T14:35:51.195Z: LoadService: trying fileInClasspath: gems/bundler-1.9.8/lib/logger.jar
2015-05-15T14:35:51.195Z: LoadService: trying fileInClasspath: logger.jar
LoadError: no such file to load -- logger
          require at org/jruby/RubyKernel.java:966
            <top> at /app/blaine.jar!/gems/frenzy_bunnies-0.0.8/lib/frenzy_bunnies/context.rb:1
          require at org/jruby/RubyKernel.java:966
            <top> at /app/blaine.jar!/gems/frenzy_bunnies-0.0.8/lib/frenzy_bunnies.rb:1
          require at org/jruby/RubyKernel.java:966
  block in (root) at /app/blaine.jar!/gems/frenzy_bunnies-0.0.8/lib/frenzy_bunnies.rb:11
             each at org/jruby/RubyArray.java:1571
  block in (root) at /app/blaine.jar!/gems/bundler-1.9.8/lib/bundler/runtime.rb:1
             each at org/jruby/RubyArray.java:1571
          require at /app/blaine.jar!/gems/bundler-1.9.8/lib/bundler/runtime.rb:76
          require at /app/blaine.jar!/gems/bundler-1.9.8/lib/bundler/runtime.rb:72
            <top> at /app/blaine.jar!/gems/bundler-1.9.8/lib/bundler/runtime.rb:61
             load at org/jruby/RubyKernel.java:984
            <top> at /app/blaine.jar!/gems/bundler-1.9.8/lib/bundler.rb:134
          require at org/jruby/RubyKernel.java:966
           (root) at uri:classloader:/blaine/bin/blaine:8
            <top> at uri:classloader:/META-INF/main.rb:1
ERROR: org.jruby.embed.EvalFailedException: (LoadError) no such file to load -- logger

This repeats for all stdlib classes that I try and require. Executing environment is:

  • JRuby 9k pre2
  • Warbler commit Sha: 50b8660

Warbler config is in this gist.

Any feedback would be great - thanks!

@mkristian
Copy link
Member Author

this looks like the bug (which I never got around to submit a PR) in
bundler where it wipes out the default $LOAD_PATH of JRuby.

usually you need to see things like:

LoadService: trying fileResource:
uri:classloader://META-INF/.jruby.home/lib/ruby/stdlib/logger.rb

if you look at you debug output I am sure before JRuby found bundler there
are some LoadService: trying fileResource: uri:classloader://META-INF/.jruby.home/lib/ruby/stdlib/....
attempts.

in jruby-mains I work around this with:
https://github.com/mkristian/jruby-mains/blob/master/src/main/java/de/saumya/mojo/mains/JRubyMain.java#L84
and
https://github.com/mkristian/jruby-mains/blob/master/src/main/java/de/saumya/mojo/mains/JRubyMain.java#L99

the ENV thing you can add to your WEB-INF/init.rb file

@mkristian
Copy link
Member Author

@jgwmaxwell if the BUNDLE_DISABLE_SHARED_GEMS env helps you, we should consider it to add it to the default init.rb of warbler.

@jkutner maybe it is worth added it any ways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants