postmodern / chruby

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

JRuby affecting other rubies #332

Open fgarcia opened 9 years ago

fgarcia commented 9 years ago

Somehow JRuby rubies are affecting my MRI rubies.

First I install some MRI rubies:

ruby-build 2.2.1 /opt/rubies/2.2.1
ruby-build 2.1.5 /opt/rubies/2.1.5

And everything works fine until I install some JRuby version

ruby-build jruby-9.0.0.0.pre1 /opt/rubies/jruby-9.0.0.0.pre1

After this, every single use of bundler in MRI rubies will complain about jruby-launcher

> chruby 2.2.1
> bundler
Ignoring jruby-launcher-1.1.1-java because its extensions are not built.  Try: gem pristine jruby-launcher --version 1.1.1
theunraveler commented 9 years ago

I'm having this issue as well. It looks like bundler checks for a jruby file in the $BINDIR in various places, and assumes you're using jRuby if it exists. For example:

ifeq (true,$(shell test -x $(BINDIR)/jruby && echo true))
RAKE=$(BINDIR)/jruby -S rake
else
RAKE=rake
endif
postmodern commented 9 years ago

Guessing that bundler is coming from the system. Run gem install bundler and that should install bundle(r) into ~/.gem/....

fgarcia commented 9 years ago

Bundler was working OK before installing jruby, and despite the type command showing that the right binary was called, I also tried calling it directly with the full path.

postmodern commented 9 years ago

What does head $(which bundler) show?

jrochkind commented 9 years ago

I'm having this happening too, it started only recently for me. Get that message when running things under MRI, switched to MRI via chruby.

Sounds like other users may be using chruby too, the problem maybe exhibits specifically under the sort of ENV-herding that chruby does to switch rubies?

$ bundle -v
Bundler version 1.9.4

$ head $(which bundler)

#!/opt/rubies/ruby-2.2.2/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'bundler' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'
fgarcia commented 9 years ago

This is my output:

$ chruby
  2.1.6
  2.2.1
* 2.2.2 
  jruby-9.0.0.0.pre2

$ bundle -v
Bundler version 1.9.9

$ head $(which bundler)
#!/opt/rubies/2.2.2/bin/ruby
#
# This file was generated by RubyGems.
#
# The application 'bundler' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

The warning of bundle install only appears after install jruby

$ bundle install
Ignoring jruby-launcher-1.1.1-java because its extensions are not built.  Try: gem pristine jruby-launcher --version 1.1.1
Resolving dependencies...

I solved this problem by removing my rubies and ~/.gem folders. However to reproduce this issue I installed jruby again and got the same warning. It stays there even if I delete jruby

fgarcia commented 9 years ago

After deleting jruby I realized I could fix the warning by also removing the gem.

 gem uninstall jruby-launcher-1.1.1-java

So I am no longer sure this is a real chruby issue

jrochkind commented 9 years ago

I don't understand how the gem got installed under chruby mri in the first place. I wouldn't want to delete the gem from my jruby gem installation, but it ought not to be there in MRI clearly.

I still don't understand what's going on.

jrochkind commented 9 years ago

And indeed it does NOT seem to be installed under my MRI ruby.

Check out this confusing output, where running gem which first issues the jruby-launcher error message, then tells me there's no jruby-launcher gem installed.

$ ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin12.0]
$ gem which jruby-launcher
Ignoring jruby-launcher-1.1.1-java because its extensions are not built.  Try: gem pristine jruby-launcher --version 1.1.1
ERROR:  Can't find ruby library file or shared library jruby-launcher

If you delete the gem, you should make sure you are NOT deleting it from the actual jruby installation, as that would be undesirable.

jrochkind commented 9 years ago

@postmodern, Any interest in fixing this or helping to figure out what's causing it? It's kind of annoying.

Is it not happening to everyone, but only to a few of us, some quirk of our install setup?

postmodern commented 9 years ago

Fairly busy, but I'm not quite sure how this error occurs. Does gem pristine help at all?

jrochkind commented 9 years ago

So I can't run gem pristine jruby-launcher from MRI 2.2.2, becuase jruby-launcher isn't installed at all in MRI 2.2.2, and presumably isn't installable under MRI (trying it gets some confusing errors).

It's still really a mystery where that error message is coming from -- running just about anything involving gems in MRI 2.2.2 (including bundle exec) ends up outputting to console Ignoring jruby-launcher-1.1.1-java because its extensions are not built.

Just for the heck of it, I can try running gem pristine jruby-launcher --version 1.1.1 from Jruby....

Huh, that seems to have worked. How odd. chruby jruby ; gem pristine ..... Then switch back to MRI 2.2.2, the error message on any action seems to be gone. For now? Hopefully.

Very odd.

postmodern commented 9 years ago

What about gem pristin --all in MRI? Also, is another dependency pull in jruby-launcher in the Gemfile.lock?

jrochkind commented 9 years ago

Oddly and while I can't explain, the gem pristine jruby-launcher in Jruby seems to have fixed the probelm exhibiting under MRI, so I can't reproduce it anymore myself, so can't test to see if a gem pristine --all in MRI would have fixed it.

I'm not sure if there was actually a Gemfile.lock involved at all though -- the problem could reproduce simply by doing a gem which anything, even, I think, in a directory that didn't have a Gemfile at all. Maybe. Can't reproduce anymore, so hard to say now. I'll let anyone else who is still reproducing follow up more, or come back if it happens again!

fgarcia commented 9 years ago

I am not sure if this was the case before, but this is the current status:

ruby-build 2.2.0 /opt/rubies/2.2.0
ruby-build jruby-9.0.0.0 /opt/rubies/jruby-9000
chruby 2.2.0

Warnings everywhere about jruby-launcher

chruby jruby-9000
gem install jruby-launcher
chruby 2.2.0

Now everything is OK

mcandre commented 8 years ago

I get similar errors about extensions, without using any JRuby stuff.

El Capitan.

jrochkind commented 8 years ago

Started happening for me again on a new machine. I can try to investigate more details, if you tell me what to look at. Otherwise, I'll just chruby jruby ; gem pristine jruby-launcher, which fixed it last time, and probably will again.