Lieven Cardoen
Lieven Cardoen

Reputation: 25959

Which gems is JRuby Rails using?

If I startup my WEBrick server using

bundle exec jruby -S rails s

I'm getting following warning

c:/Program Files/jruby-1.6.7/lib/ruby/gems/1.8/gems/activesupport-
  3.2.2.rc1/lib/active_support/core_ext/string/output_safety.rb:34 
  warning: regexp match /.../n against to UTF-8 string

Now, don't mind the warning, that's not part of my question. What is part of the question is why gems from 1.8 are being used when JRuby is set to used 1.9 mode?

$ bundle exec jruby -S rails s
=> Booting WEBrick
=> Rails 3.2.2.rc1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-03-05 13:41:02] INFO  WEBrick 1.3.1
[2012-03-05 13:41:02] INFO  ruby 1.9.2 (2012-02-22) [java]
[2012-03-05 13:41:02] INFO  WEBrick::HTTPServer#start: pid=7624 port=3000

Version:

$ jruby -v
jruby 1.6.7 (ruby-1.9.2-p312) (2012-02-22 3e82bc8) 
  (Java HotSpot(TM) Client VM 1.6.0_27) [Windows Vista-x86-java]

Upvotes: 3

Views: 1031

Answers (1)

This got me curious too! (=

Irrespective of the mode you are using, the master repo for gem is in the 1.8 directory:

$ jruby -S gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.9
  - RUBY VERSION: 1.8.7 (2011-10-25 patchlevel 330) [java]
  - INSTALLATION DIRECTORY: C:/dev/jruby-1.6.5/lib/ruby/gems/1.8
...

  - GEM PATHS:
     - C:/dev/jruby-1.6.5/lib/ruby/gems/1.8
     - C:/.gem/jruby/1.8

And with --1.9:

$ jruby --1.9 -S gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.9
  - RUBY VERSION: 1.9.2 (2011-10-25 patchlevel 136) [java]
  - INSTALLATION DIRECTORY: C:/dev/jruby-1.6.5/lib/ruby/gems/1.8
...

  - GEM PATHS:
     - C:/dev/jruby-1.6.5/lib/ruby/gems/1.8
     - C:/.gem/jruby/1.9

The installation directory is set at JRuby compile time by the jruby.gem.home which is set by default to:

jruby.gem.home.1.8=lib/ruby/gems/1.8

(in default.build.properties in the JRuby codebase)

However, this shouldn't be a problem because when running in --1.9 mode, the LOAD_PATH contains 1.8.

$ jruby --1.9 -rpp -e 'pp $LOAD_PATH'
["C:/dev/jruby-1.6.5/lib/ruby/site_ruby/1.9",
 "C:/dev/jruby-1.6.5/lib/ruby/site_ruby/shared",
 "C:/dev/jruby-1.6.5/lib/ruby/site_ruby/1.8",
 "C:/dev/jruby-1.6.5/lib/ruby/1.9"]

Upvotes: 2

Related Questions