postmodern / chruby

Changes the current Ruby
MIT License
2.85k stars 190 forks source link

chruby and .jrubyrc files #343

Open deivid-rodriguez opened 8 years ago

deivid-rodriguez commented 8 years ago

chruby fails in jruby with a project containing a .jrubyrc file with the cli.load.gemfile=true configuration.

postmodern commented 8 years ago

Could you provide me with an error message? I'm curious what's breaking when we invoke bin/jruby.

deivid-rodriguez commented 8 years ago

@postmodern Just tried this and I can no longer reproduce it. Closing.

deivid-rodriguez commented 8 years ago

Actually, got it! It happens when switching from another ruby in the apps folder containing the .jrubyrc file.

LoadError: no such file to load -- bundler/setup
  require at org/jruby/RubyKernel.java:939
  require at /Users/deivid/.rubies/jruby-9.0.4.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54
    <top> at file:/Users/deivid/.rubies/jruby-9.0.4.0/lib/jruby.jar!/jruby/bundler/startup.rb:4
postmodern commented 8 years ago

@deivid-rodriguez guessing the exception is happening during jruby startup, and not from the code we pipe into the ruby. Is this a chicken and egg problem, where we need to gem install bundler under jruby, but can't invoke bin/jruby because the lack of bundler? Ideally, jruby should print a warning and keep executing.

deivid-rodriguez commented 8 years ago

But bundler is installed... After commenting out the .jrubyrc:

$ chruby ruby
$ chruby
 * jruby-9.0.4.0
   ruby-2.0.0-p648
   ruby-2.1.8
   ruby-2.2.4
   ruby-2.3.0-preview2
$ bundle --version
Bundler version 1.11.2
postmodern commented 8 years ago

That's because when chruby first invokes jruby, GEM_HOME isn't set so jruby can't find bundler.