本地项目RoR项目中的rubygems.rb(LoadError)

时间:2014-09-08 09:03:35

标签: ruby-on-rails ruby rvm

我需要在当前项目中使用Rails 2.1.1和Ruby 3.2.13。

无法在本地启动rails服务器。我使用RVM来管理rails版本。

这是我在项目文件夹内的终端中的日志:

$ rvm use 2.1.1
Using .../.rvm/gems/ruby-2.1.1
<internal:gem_prelude>:1:in `require': cannot load 
such file -- rubygems.rb (LoadError)
from <internal:gem_prelude>:1:in `<compiled>'
$ ruby -v
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin12.0]
$ which ruby
.../.rvm/rubies/ruby-2.1.1/bin/ruby
$ rails server
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.1
$ rvm list

rvm rubies

   ruby-2.0.0-p451 [ x86_64 ]
=* ruby-2.1.1 [ x86_64 ]
   ruby-2.1.2 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

有什么问题?我需要看哪里?谢谢!

1 个答案:

答案 0 :(得分:2)

最常见的原因:

$ rails server
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.1

是从错误的ruby版本中使用rails命令(/ gem)来修复它运行:

rvm use . --install          # switch to proper ruby
rvm rubygems latest --force  # make sure rubygems is installed in this ruby
gem install bundler          # make sure bundler is installed
bundle install               # make sure all gems for your project are installed