Rails找不到已安装的gem

时间:2015-05-26 19:30:13

标签: ruby-on-rails ruby ruby-on-rails-3 railstutorial.org

我正在关注专门要求版本4.2.0的Rails教程,所以我用sudo gem install rails -v 4.2.0安装了Rails并且它工作正常。当我尝试使用rails _4.2.0 new test_app创建新应用程序时,我收到一条错误消息,上面写着/Library/Ruby/Site/2.0.0/rubygems/dependency.rb.315: in 'to_specs': Could not find 'railties' (=4.2.0) - did find: [railties-4.2.1] (Gem::LoadError),并继续了一段时间。

我已尝试使用railties安装特定版本的sudo gem install railties -v 4.2.0,但我仍然遇到同样的错误。是在两个不同的地方检查/安装宝石吗?

编辑:正在运行gem list会产生以下输出,清楚地显示railties (4.2.0)

*** LOCAL GEMS ***

actionmailer (4.2.0)
actionpack (4.2.1, 4.2.0)
actionview (4.2.1, 4.2.0)
activejob (4.2.1, 4.2.0)
activemodel (4.2.0)
activerecord (4.2.0)
activesupport (4.2.1, 4.2.0)
arel (6.0.0)
bigdecimal (1.2.6)
builder (3.2.2)
bundler (1.9.9)
erubis (2.7.0)
globalid (0.3.5)
i18n (0.7.0)
io-console (0.4.3)
json (1.8.2, 1.8.1)
loofah (2.0.2)
mail (2.6.3)
mime-types (2.6.1)
mini_portile (0.6.2)
minitest (5.6.1, 5.4.3)
nokogiri (1.6.6.2)
power_assert (0.2.2)
psych (2.0.8)
rack (1.6.1)
rack-test (0.6.3)
rails (4.2.0)
rails-deprecated_sanitizer (1.0.3)
rails-dom-testing (1.0.6)
rails-html-sanitizer (1.0.2)
railties (4.2.0)
rake (10.4.2)
rdoc (4.2.0)
sprockets (3.1.0)
sprockets-rails (2.3.1)
test-unit (3.0.8)
thor (0.19.1)
thread_safe (0.3.5)
tzinfo (1.2.2)

1 个答案:

答案 0 :(得分:1)

你不应该使用sudo来安装宝石。使用rbenv