Rails 新人求解:好神奇,纯安装 Rails 4.0.0 不行,要先装个 Rails 3.0.3

295567172 · 2013年07月24日 · 最后由 Rei 回复于 2013年07月24日 · 3947 次阅读

我输入 gem install rails --version 4.0.0 安装,然后输入 rails -v 时,提示如下:

/usr/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find minitest (~> 4.2) amongst [abstract-1.0.0, actionmailer-4.0.0, actionmailer-3.0.3, actionmailer-2.2.2, actionpack-4.0.0, actionpack-3.0.3, actionpack-2.2.2, activemodel-4.0.0, activemodel-3.0.3, activerecord-4.0.0, activerecord-3.0.3, activerecord-2.2.2, activerecord-deprecated_finders-1.0.3, activeresource-4.0.0, activeresource-3.0.3, activeresource-2.2.2, activesupport-4.0.0, activesupport-3.0.3, activesupport-2.2.2, arel-4.0.0, arel-2.0.10, atomic-1.1.10, bigdecimal-1.2.1, builder-3.2.2, builder-3.1.4, builder-2.1.2, bundler-1.3.5, bundler-unload-1.0.1, erubis-2.7.0, erubis-2.6.6, hike-1.2.3, i18n-0.6.4, json-1.8.0, mail-2.5.4, mail-2.2.20, mime-types-1.23, minitest-5.0.6, multi_json-1.7.7, polyglot-0.3.3, rack-1.5.2, rack-1.2.8, rack-mount-0.6.14, rack-test-0.6.2, rack-test-0.5.7, rails-4.0.0, rails-observers-0.1.2, railties-4.0.0, railties-3.0.3, rake-10.1.0, rdoc-4.0.1, rubygems-bundler-1.2.2, rvm-1.11.3.8, sprockets-2.10.0, sprockets-rails-2.0.0, test-unit-2.5.5, thor-0.18.1, thor-0.14.6, thread_safe-0.1.2, thread_safe-0.1.0, tilt-1.4.1, treetop-1.4.14, tzinfo-1.0.1, tzinfo-0.3.37] (Gem::LoadError)
    from /usr/lib/ruby/1.9.1/rubygems/specification.rb:777:in `block in activate_dependencies'
    from /usr/lib/ruby/1.9.1/rubygems/specification.rb:766:in `each'
    from /usr/lib/ruby/1.9.1/rubygems/specification.rb:766:in `activate_dependencies'
    from /usr/lib/ruby/1.9.1/rubygems/specification.rb:750:in `activate'
    from /usr/lib/ruby/1.9.1/rubygems/specification.rb:780:in `block in activate_dependencies'
    from /usr/lib/ruby/1.9.1/rubygems/specification.rb:766:in `each'
    from /usr/lib/ruby/1.9.1/rubygems/specification.rb:766:in `activate_dependencies'
    from /usr/lib/ruby/1.9.1/rubygems/specification.rb:750:in `activate'
    from /usr/lib/ruby/1.9.1/rubygems.rb:1232:in `gem'
    from /usr/local/bin/rails:22:in `<main>'

然后我输入 gem list rails,提示如下:

LOCAL GEMS
rails (4.0.0)
rails-observers (0.1.2)

**最后我输入 gem install rails --version 3.0.3,安装成功后,再输入 rails -v,提示如下:

Rails 4.0.0

好神奇,这到底是为什么呢?我的 Ruby 版本是 2.0.0,新人求解 😊

你说你的 Ruby 是 2.0.0,可是第二行 /usr/lib/ruby/1.9.1/rubygems/dependency.rb:247 确说是 1.9.1?

系统 Ruby ? rubygems 版本太久了。用 rvm 或 rbenv。

#1 楼 @steveLTN 因为我用 RVM 管理 ruby,所以有很多个 Ruby 版本,但是已经切换到到 2.0.0 咯,我输入 ruby -v 可以看到是 2.0.0 😗

如果你用的是 rvm,$GEM_PATH 应该是 /Users/username/.rvm/gems/ruby-2.0.0-p247 这样的。你的 gempath 却指向 1.9.1 的目录?

#2 楼 @Rei 我就是用 RVM 哦,不太明白 $ rvm -v rvm 1.21.11 (stable) by Wayne E. Seguin [email protected], Michal Papis [email protected] [https://rvm.io/]

#4 楼 @steveLTN 我也不知道哦,好复杂 0.0

#4 楼 @steveLTN 难道因为我用 RVM 装 Ruby 前,用过纯 Ruby 安装?

#5 楼 @295567172 没安装完成,调用的是系统 Ruby。你没说明安装环境,我猜测是这个问题 https://rvm.io/integration/gnome-terminal

你安装 rvm 后,更新系统环境变量了吗?

#9 楼 @steveLTN 请问怎么更新系统环境变量?

#10 楼 @295567172 source ~/.bash_rc,或者就直接重新启动一下 shell

#8 楼 @Rei 这里我的确没设置,但是一定要设置吗?总之谢谢咯

#12 楼 @295567172 必须。那页面写有原因。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号