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

Rails.root set to "uri:classloader:/" for new Rails app with JRuby 9.0.0.0 #3233

Closed
donv opened this issue Aug 7, 2015 · 8 comments
Closed

Rails.root set to "uri:classloader:/" for new Rails app with JRuby 9.0.0.0 #3233

donv opened this issue Aug 7, 2015 · 8 comments

Comments

@donv
Copy link
Member

@donv donv commented Aug 7, 2015

For a new Rails app running the Rails runner prefixed with jruby -S make Rails.root get the value uri:classloader:/. Starting without the jruby -S prefix works as expected.

$ rvm use jruby
Using /Users/uwe/.rvm/gems/jruby-9.0.0.0
$ gem install rails
Successfully installed rails-4.2.3
$ rails new test_app
      create  
      ...
$ cd test_app
$ ruby -S rails r "puts Rails.root"
uri:classloader:/
$ rails r "puts Rails.root"
/Users/uwe/workspace/jruby/test_app

The effect is the same with JRuby installed via RVM or by downloading and unpacking the JRuby 9.0.0.0 tarball.

@donv donv added this to the JRuby 9.0.1.0 milestone Aug 7, 2015
@donv
Copy link
Member Author

@donv donv commented Aug 7, 2015

Reproduced on OS X 10.10.4 and Centos 5.11.

@donv donv changed the title Rails.root set to for new Rails app with JRuby 9.0.0.0 Rails.root set to "uri:classloader:/" for new Rails app with JRuby 9.0.0.0 Aug 7, 2015
@donv
Copy link
Member Author

@donv donv commented Aug 7, 2015

Same behaviour using Java 8 or Java 7.

@mkristian
Copy link
Member

@mkristian mkristian commented Aug 7, 2015

needs rvm to reproduce it !!!

@mkristian mkristian closed this in c925dbf Aug 7, 2015
@mkristian
Copy link
Member

@mkristian mkristian commented Aug 7, 2015

the only workaround I know is to use "rbenv" instead of "rvm"

@donv
Copy link
Member Author

@donv donv commented Aug 7, 2015

@mkristian do you know what rbenv does differently?

@mkristian
Copy link
Member

@mkristian mkristian commented Aug 7, 2015

@donv rbenv installs the bin stubs in JRUBY_HOME/bin (which is actually the default from dist install as well) - not sure where rvm installs them. but JRUBY_HOME/bin is the first location it looks for bin files. then comes the classpath where things fail for rails.

@donv
Copy link
Member Author

@donv donv commented Aug 7, 2015

A simple workaround is to specify the relative path to the binary:

$ ruby -S rails r 'puts $0'
uri:classloader:/bin/rails
$ ruby -S bin/rails r 'puts $0'
bin/rails
 jruby -S rails r "puts Rails.root"
uri:classloader:/
$ jruby -S bin/rails r "puts Rails.root"
/Users/uwe/workspace/jruby/test_app
@donv
Copy link
Member Author

@donv donv commented Aug 7, 2015

Verified that it works with jruby-head from RVM:

$ rvm use jruby-head
Using /Users/uwe/.rvm/gems/jruby-head
$ ruby -v
jruby 9.0.1.0-SNAPSHOT (2.2.2) 2015-08-07 926fbb7 Java HotSpot(TM) 64-Bit Server VM 25.51-b03 on 1.8.0_51-b16 +jit [darwin-x86_64]
$ jruby -S rails r "puts Rails.root"
/Users/uwe/workspace/jruby/test_app
$ ruby -S rails r 'puts $0'
/Users/uwe/workspace/jruby/test_app/bin/rails
mkristian added a commit that referenced this issue Aug 10, 2015
…ted as files

jruby always looks on classpath in 'bin' for executables but finding
it there leads to uri:classloader:/bin/rails which can have side effects.
looking first on the filesystem ./bin will find bin/rails instead.

fixes #3233 and partially #3216

Sponsored by Lookout Inc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants