使用了错误的红宝石版本

时间:2011-12-02 01:02:19

标签: ruby-on-rails

我正试图在运行狮子的我的mac上运行rails。我正在使用rvm并且它显示我正在使用ruby 1.9.2p312但是当我去启动服务器时我得到一个引用ruby 1.8的错误并且没有安装rails,即使在此错误之前我运行了bundle install和它成功安装了我需要的一切。

关于如何解决这个问题的任何想法?

好吧,似乎1.8错误消失了。这是新错误和捆绑显示:

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 (wayneeseguin@gmail.com) [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:       ""

3 个答案:

答案 0 :(得分:5)

如果使用RVM,请确保在〜/ .bash_profile文件中rvm的路径位于其他路径之前。

例如,在任何PATH声明之前将它放入〜/ .bash_profile:

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

然后你的其他导出声明可能看起来像这样(这只是一个例子,你不需要把它放进去,我只是包含它,所以你看看文件的样子,但是以上你绝对需要):

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

最后,如果像我一样,你放弃了RVM并使用rbenv,那么用第一个export PATH行代替:

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

这些更改应该使系统在/System/Library/Frameworks/Ruby.framework

中的内置RVM文件之前查看您的RVM文件 祝你好运。

答案 1 :(得分:2)

我看到这已经得到了解答,但我建议只输入

gem install bundlergem update bundler

它解决了OP在没有修改Bash_profile的情况下遇到的问题。

答案 2 :(得分:0)

我认为在使用带有不同rails版本的bundle和rvm时需要运行bundle exec rails s