Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Bundler::SharedHelpers.clean_load_path does cleanup the default load_path on jruby #4565

Closed
mkristian opened this issue May 11, 2016 · 13 comments

Comments

@mkristian
Copy link
Contributor

when packing a jruby into jar the internal layout looks as such: let ROOT be the root of the jar.

JRUBY_HOME=ROOT
GEM_PATH=ROOT
GEM_HOME=ROOT

and the default load path of jruby is
$JRUBY_HOME/lib/ruby/2.3/site_ruby, $JRUBY_HOME/lib/ruby/stdlib

in such a setup Bundler::SharedHelpers.clean_load_path will wipe out the default load_path and you will see errors like:

LoadError: no such file to load -- bundler/dep_proxy
  block in expand_dependencies at uri:classloader:/gems/bundler-1.12.3/lib/bundler/definition.rb:630
                          each at org/jruby/RubyArray.java:1593
  block in expand_dependencies at uri:classloader:/gems/bundler-1.12.3/lib/bundler/definition.rb:629
                          each at org/jruby/RubyArray.java:1593
           expand_dependencies at uri:classloader:/gems/bundler-1.12.3/lib/bundler/definition.rb:626
         converge_locked_specs at uri:classloader:/gems/bundler-1.12.3/lib/bundler/definition.rb:594
                       resolve at uri:classloader:/gems/bundler-1.12.3/lib/bundler/definition.rb:195
                         specs at uri:classloader:/gems/bundler-1.12.3/lib/bundler/definition.rb:140
                     specs_for at uri:classloader:/gems/bundler-1.12.3/lib/bundler/definition.rb:185
               requested_specs at uri:classloader:/gems/bundler-1.12.3/lib/bundler/definition.rb:174
               requested_specs at uri:classloader:/gems/bundler-1.12.3/lib/bundler/environment.rb:19
                         setup at uri:classloader:/gems/bundler-1.12.3/lib/bundler/runtime.rb:14
                         setup at uri:classloader:/gems/bundler-1.12.3/lib/bundler.rb:95
                         <top> at uri:classloader:/json-bundler-warbler/bin/run.rb:3
                          load at org/jruby/RubyKernel.java:962
                         <top> at uri:classloader:/META-INF/main.rb:1
                       require at org/jruby/RubyKernel.java:944
                        (root) at uri:classloader:/META-INF/main.rb:1
                         <top> at uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1
ERROR: org.jruby.embed.EvalFailedException: (LoadError) no such file to load -- bundler/dep_proxy

see https://gist.github.com/mkristian/5738370aba7d6cbe38d516cfdc07d992 for a complete example.

I did monkey patch with jruby-mains like this: https://github.com/jruby/jruby-mains/blob/master/src/main/resources/META-INF/monkey_patches.rb#L9 for some time now. but warbler does not have this monkey patch, so warblers packed jar files can fail when using bundler.

PR is coming

mkristian added a commit to mkristian/bundler that referenced this issue May 11, 2016
jruby does not add default gems explicitly to the load path and the cleaning
of the load path wipes out the default laod_path of jruby in cases where
JRUBY_HOME == GEM_HOME

fixes rubygems#4565
@mkristian
Copy link
Contributor Author

this issue came forward during investigation of jruby/jruby#3850

mkristian added a commit to mkristian/bundler that referenced this issue May 11, 2016
…ruby

JRuby sometime produces uri:classloader:/gems/bundler-1.12.3/lib
paths and sometimes uri:classloader://gems/bundler-1.12.3/lib
due to some file-path normalization not able to keep uri prefixes
intact. those uri-like paths mainly happen when loading resources
from the jar-file or classloader.

fixes rubygems#4565
@headius
Copy link
Contributor

headius commented May 11, 2016

👍 We need to get this out there ASAP so folks running into problems bundling apps into jars can still deploy their apps. Let me know what I can do to help.

mkristian added a commit to mkristian/bundler that referenced this issue May 11, 2016
…ruby

JRuby sometime produces uri:classloader:/gems/bundler-1.12.3/lib
paths and sometimes uri:classloader://gems/bundler-1.12.3/lib
due to some file-path normalization not able to keep uri prefixes
intact. those uri-like paths mainly happen when loading resources
from the jar-file or classloader.

fixes rubygems#4565
@coilysiren
Copy link
Contributor

@headius you may want to pick up the work @mkristian started doing on #4566

@headius
Copy link
Contributor

headius commented May 18, 2016

@lynnco Pick it up? You mean test that it works?

@headius
Copy link
Contributor

headius commented May 18, 2016

@lynnco Ok, so I guess you are saying we should fix #3881 before we consider a patch to Bundler. I'll clarify with @mkristian whether this bug is still valid.

@coilysiren
Copy link
Contributor

@headius it seems like this was a jruby issue that Bundler code could have helped solve, so it would be ok to send a patch to resolve it on Bundler's end.

But if jruby is no longer experiencing the issue then I dont think it's worth your time to work on the Bundler PR

@mkristian
Copy link
Contributor Author

on warbler I am working on patch to fix this problem here. packing ruby application with gradle or maven works already with a monkey patch for bundler. it is clearly a jruby issue when jruby tries to normalize those uri-like paths which is still treated as regular path on filesystem.

@coilysiren coilysiren added this to the 1.X -- Better Platform Support milestone Jun 6, 2016
@coilysiren coilysiren changed the title Bundler::SharedHelpers.clean_load_path does cleanup the default load_path on jruby [jruby] Bundler::SharedHelpers.clean_load_path does cleanup the default load_path on jruby Jun 6, 2016
@coilysiren coilysiren changed the title [jruby] Bundler::SharedHelpers.clean_load_path does cleanup the default load_path on jruby Bundler::SharedHelpers.clean_load_path does cleanup the default load_path on jruby Jun 6, 2016
@mikegee
Copy link

mikegee commented Nov 29, 2017

Is this issue still relevant?

dmikurube added a commit to embulk/embulk that referenced this issue Nov 30, 2017
…Helpers.clean_load_path: Fix #861

Bundler has had a problem in running with JRuby.
See rubygems/bundler#4565 for the details.
@dmikurube
Copy link

I'm also concerned about this issue. Not sure of the status -- will it be fixed on Bundler side, or does jruby/jruby#3881 on JRuby side fix it?

@mkristian
Copy link
Contributor Author

oh - it never got fixed on the JRuby side :(
the problem is that there is some path normalization code which reduces :// to :/ and there is probably more then one place where the actual normalization takes place. fixing it on jruby is error prune but eventually needed. the attached patch in the issue, is a workaround for a JRuby quirk but reliable.

@deivid-rodriguez
Copy link
Member

Is this issue still an issue? Can you try with the latest bundler? I think #6502 might've fixed this.

@deivid-rodriguez
Copy link
Member

Closing due to lack of feedback.

@headius
Copy link
Contributor

headius commented Jan 20, 2020

I have not heard of this being an issue for anyone in quite some time, so we'll assume it has been resolved.

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

Successfully merging a pull request may close this issue.

6 participants