Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong ruby version being used

I'm trying to get rails running on my mac which is running lion. I'm using rvm and it shows I'm using ruby 1.9.2p312 but when I go to start the server I'm getting an error referencing ruby 1.8 and that rails is not installed even though previous to this error I ran bundle install and it installed everything I needed successfully.

Any ideas on how to solve this?

Ok, it seems that the 1.8 error has gone away. Here is the new error and bundle show:

bundle exec rails s
/Users/anthonyd/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require': no such file to load -- spec (LoadError)
    from /Users/anthonyd/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/anthonyd/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
    from /Users/anthonyd/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/anthonyd/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
    from /Users/anthonyd/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
    from /Users/anthonyd/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
    from /Users/anthonyd/Sites/rails/reminders/config/application.rb:7:in `<top (required)>'
    from /Users/anthonyd/.rvm/gems/ruby-1.9.2-head/gems/railties-3.1.3/lib/rails/commands.rb:52:in `require'
    from /Users/anthonyd/.rvm/gems/ruby-1.9.2-head/gems/railties-3.1.3/lib/rails/commands.rb:52:in `block in <top (required)>'
    from /Users/anthonyd/.rvm/gems/ruby-1.9.2-head/gems/railties-3.1.3/lib/rails/commands.rb:49:in `tap'
    from /Users/anthonyd/.rvm/gems/ruby-1.9.2-head/gems/railties-3.1.3/lib/rails/commands.rb:49:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'


bundle show
Gems included by the bundle:
  * actionmailer (3.1.3)
  * actionpack (3.1.3)
  * activemodel (3.1.3)
  * activerecord (3.1.3)
  * activeresource (3.1.3)
  * activesupport (3.1.3)
  * arel (2.2.1)
  * aws-s3 (0.6.2)
  * bbenezech-nested_form (0.0.2)
  * bcrypt-ruby (3.0.1)
  * bootstrap-sass (1.4.0)
  * builder (3.0.0)
  * bundler (1.0.21)
  * coffee-rails (3.1.1)
  * coffee-script (2.2.0)
  * coffee-script-source (1.1.3)
  * devise (1.5.2 b303429)
  * diff-lcs (1.1.3)
  * erubis (2.7.0)
  * execjs (1.2.9)
  * haml (3.1.4)
  * hike (1.2.1)
  * hpricot (0.8.5)
  * i18n (0.6.0)
  * jquery-rails (1.0.19)
  * json (1.6.3)
  * kaminari (0.12.4)
  * mail (2.3.0)
  * mime-types (1.17.2)
  * multi_json (1.0.4)
  * nokogiri (1.5.0)
  * orm_adapter (0.0.5)
  * polyglot (0.3.3)
  * rack (1.3.5)
  * rack-cache (1.1)
  * rack-mount (0.8.3)
  * rack-pjax (0.5.5)
  * rack-ssl (1.3.2)
  * rack-test (0.6.1)
  * rails (3.1.3)
  * rails_admin (0.0.1 6120ad4)
  * railties (3.1.3)
  * rake (0.9.2.2)
  * rdoc (3.11)
  * remotipart (1.0.1)
  * rspec (2.7.0)
  * rspec-core (2.7.1)
  * rspec-expectations (2.7.0)
  * rspec-mocks (2.7.0)
  * sass (3.1.11)
  * sass-rails (3.1.5)
  * sprockets (2.0.3)
  * sqlite3 (1.3.4)
  * sqlite3-ruby (1.3.3)
  * thor (0.14.6)
  * tilt (1.3.3)
  * treetop (1.4.10)
  * tzinfo (0.3.31)
  * warden (1.1.0)
  * xml-simple (1.1.1)

rails s
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:777:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:211:in `activate'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:1056:in `gem'
    from /usr/bin/rails:18

**ruby -v**
ruby 1.9.2p312 (2011-08-11 revision 32926) [x86_64-darwin11.2.0]

**RVM Info**:

system:
    uname:       "Darwin Anthony-DeFreitass-MacBook-Pro.local 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug  9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64"
    bash:        "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)"
    zsh:         "/bin/zsh => zsh 4.3.11 (i386-apple-darwin11.0)"

  rvm:
    version:      "rvm 1.10.0-pre by Wayne E. Seguin ([email protected]) [https://rvm.beginrescueend.com/]"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.2p312"
    date:         "2011-08-11"
    platform:     "x86_64-darwin11.2.0"
    patchlevel:   "2011-08-11 revision 32926"
    full_version: "ruby 1.9.2p312 (2011-08-11 revision 32926) [x86_64-darwin11.2.0]"

  homes:
    gem:          "/Users/anthonyd/.rvm/gems/ruby-1.9.2-head"
    ruby:         "/Users/anthonyd/.rvm/rubies/ruby-1.9.2-head"

  binaries:
    ruby:         "/Users/anthonyd/.rvm/rubies/ruby-1.9.2-head/bin/ruby"
    irb:          "/Users/anthonyd/.rvm/rubies/ruby-1.9.2-head/bin/irb"
    gem:          "/Users/anthonyd/.rvm/rubies/ruby-1.9.2-head/bin/gem"
    rake:         "/Users/anthonyd/.rvm/gems/ruby-1.9.2-head/bin/rake"

  environment:
    PATH:         "/Users/anthonyd/.rvm/gems/ruby-1.9.2-head/bin:/Users/anthonyd/.rvm/gems/ruby-1.9.2-head@global/bin:/Users/anthonyd/.rvm/rubies/ruby-1.9.2-head/bin:/Users/anthonyd/.rvm/bin:/usr/bin:/usr/local/bin:/Users/anthonyd:/Users/anthonyd/imagemagick/bin:/Users/anthonyd/imagemagick/lib:.rvm/scripts/rvm:/usr/local/sbin:/usr/local/mysql/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin"
    GEM_HOME:     "/Users/anthonyd/.rvm/gems/ruby-1.9.2-head"
    GEM_PATH:     "/Users/anthonyd/.rvm/gems/ruby-1.9.2-head:/Users/anthonyd/.rvm/gems/ruby-1.9.2-head@global"
    MY_RUBY_HOME: "/Users/anthonyd/.rvm/rubies/ruby-1.9.2-head"
    IRBRC:        "/Users/anthonyd/.rvm/rubies/ruby-1.9.2-head/.irbrc"
    RUBYOPT:      ""
    gemset:       ""
like image 491
Anthony Avatar asked Feb 23 '23 05:02

Anthony


1 Answers

If using RVM, make sure that in your ~/.bash_profile file the path for rvm comes before the other paths.

For example, put this into your ~/.bash_profile before any PATH declarations:

export PATH=:~/.rvm/bin/:~/.rvm/gems/gems/

Then the rest of your export declarations which might look like this (this is just an example, you don't need to put it in, I'm just including it so you see how the file might look like, but the above line you definitely need):

export PATH=:~/bin/:/usr/local/Cellar/mysql/bin:/usr/local/Cellar:/usr/local/sphinx:/usr/sbin:$PATH

Finally, if, like me, you ditched RVM and went with rbenv then substitute the first export PATH line with this:

export PATH="$HOME/.rbenv/bin:$PATH"

These changes should make the system look at your RVM files before the built-in ones in /System/Library/Frameworks/Ruby.framework

Good luck.

like image 58
kakubei Avatar answered Mar 02 '23 09:03

kakubei