Rails找不到已安装的gem

我正在关注专门要求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)并继续进行一点点。

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

编辑:运行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) 

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