Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New Rails app tries to use jruby on "bundle install" when I expect it to use regular ruby, has errors?

I have done a lot of rails and ruby work in the past (using rvm, with many different types of rubies), but lately haven't done any ruby work at all. I just tried to make a new rails app to make sure my skills aren't rusty, using the following setup:

Using system ruby:

which ruby: /usr/bin/ruby
ruby -v: ruby 1.8.7 (2008-08-11> patchlevel 72) [i586-linux]

rails -v: Rails 3.0.7

when I type: rails new TestApp I get a new rails app, with a Gemfile and everything seems fine.

Inside of TestApp, when I run:

bundle install

I get:

http://pastie.org/2986861

What frustrates me is:

org/jruby/RubyArray.java:1671:in `each': Detected invalid array contents due to unsynchronized modifications with concurrent users (ConcurrencyError)
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/spec_set.rb:12:in `each'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/installer.rb:49:in `run'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/installer.rb:8:in `install'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/cli.rb:222:in `install'
from org/jruby/RubyObject.java:1334:in `send'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor/task.rb:21:in `run'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/vendor/thor/base.rb:389:in `start'
from /home/jenny/lib/ruby/gems/1.8/gems/bundler-1.0.13/bin/bundle:13:in `(root)'
from org/jruby/RubyKernel.java:1066:in `load'

Which seems to imply that the bundle is using jruby (and erroring while doing it and failing to do my bundle install).

Is there anything obviously wrong here? I'm using the default gem file included with the new rails app... (found here: http://pastie.org/2986869)

The last time I did any rails work, everything worked fine...but that was a while ago (months, maybe nearly a year?). Is there something I'm forgetting?

Edit:

which bundle: /home/jenny/bin/bundle which rails: /home/jenny/bin/rails

I don't BELIEVE myself to be using RVM at the moment, but just to be sure I made sure that rvm was pointed to the system ruby (so rvm or no, it should be using the same things).

Edit: "rvm list" gets me:

rvm list

rvm rubies

ruby-1.9.2-p136 [ i386 ]

jruby-1.3.1 [ i386-java ]

jruby-1.5.6 [ i386-java ]

ruby-1.9.2-p0 [ i386 ]

ruby-1.9.2-rc1 [ i386 ]

jruby-1.2.0 [ i386-java ]

jruby-1.6.1 [ linux-i386-java ]Exception in thread "main" java.lang.NoClassDefFoundError: org/jruby/Main Caused by: java.lang.ClassNotFoundException: org.jruby.Main at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:319) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:264) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332) Could not find the main class: org.jruby.Main. Program will exit.

jruby-head [ ]

jruby-1.6.2 [ linux-i386-java ]

jruby-1.4.0 [ i386-java ]

which doesn't look all that great, either...Deleting jruby head gets rid of that issue, but i still have the same bundle issue.

Edit: Deleting ALL jruby rvms has the same result. So, it doesn't LOOK like its RVM messing things up. Typing which jruby gets me "/home/jenny/bin/jruby". But...normally if I WANT to use jruby I have to specify it (jruby rails, for example)....bundle shouldn't be using it by default, right?

Edit (1/9/12): Updating my bundler gets me a new (very similar) error message. Specifically "Concurrency Error, invalid array contents due to unsynchronized modifications with concurrent users" with the gem "polyglot". At least no jruby weirdness. (I also uninstalled everything in rvm and reinstalled everything, which seemed to help, and am just gonna use rvm from here on out). Uninstalling polyglot and reinstalling it doesn't help at all.

In the end, I uninstalled rvm, then reinstalled it, uninstalled both my system ruby and my system jruby, and installed only ruby 1.9.2 in rvm and everything worked. Whew.

Well, at least I got through THAT problem. Now I can bundle, but not make new models? Time for a new question, I guess.

like image 963
J.R. Avatar asked Nov 04 '22 09:11

J.R.


1 Answers

Where did the bundle in your $HOME/bin come from? Is it a symlink to a file in your .rvm directory tree somewhere, or is it a script? If it's a script, what's on the first (shebang) line? Perhaps it's set to always run in JRuby?

I've seen this kind of "wrong Ruby" thing happen before, either through an executable somewhere in my $PATH ahead of the Ruby I wanted, or through RVM just plain going off into the weeds and installing gems to the wrong place.

If it were my machine, I'd try to eliminate the pool of possible (J)Rubies that might be interfering with the one I'm trying to run, something like this:

  1. Move ruby, jruby, gem, bundle, and any other Ruby-related executables from my $HOME/bin to a backup directory not on my $PATH.
  2. Rename the $HOME/.rvm tree to something not on my $PATH.
  3. Reinstall a fresh copy RVM or rbenv and add just the versions of Ruby I need.
like image 159
Erin Dees Avatar answered Nov 09 '22 13:11

Erin Dees