简体   繁体   English

Rails安装-Ruby版本不匹配

[英]Rails installation - Ruby version mismatch

I was installing rails on my machine with RVM and Ruby 2.0.0 specified in Gemfile. 我正在使用Gemfile中指定的RVM和Ruby 2.0.0在计算机上安装rails。 When I run bundle install, I get the following error: 运行捆绑安装时,出现以下错误:

Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0

When I use ruby -v , I see 当我使用ruby -v ,我看到

ruby 2.0.0p353 (2013-11-22 revision 43784) [i686-linux]

Does anyone know how to fix this? 有谁知道如何解决这一问题?

It could be that your bundle command is not from the same Ruby as ruby is. 可能是您的bundle命令与ruby来自不同的Ruby。 Always check: 经常检查:

which ruby
which bundle
which gem

These might be completely different. 这些可能完全不同。

These can get out of sync if you install bundler on your system Ruby and then install something like rbenv or rvm on top of that without it. 如果您在系统Ruby上安装bundler,然后在没有它的情况下在其上安装诸如rbenvrvm类的rbenv ,则它们可能会不同步。

Remove ruby from your Gemfile. 从您的Gemfile中删除红宝石。 Try 尝试

$ rvm list

rvm rubies

=* ruby-1.9.3-p286 [ x86_64 ]
   ruby-2.0.0-p195 [ x86_64 ]

This o/p says that 1.9.3 is the default. 此o / p表示默认值为1.9.3。 This displays all the ruby versions present in your system. 这将显示系统中存在的所有红宝石版本。 You can pick any of the versions which you want to use 您可以选择要使用的任何版本

$ rvm use version --default . $ rvm use version --default

Now 现在

$ruby -v

This must match with the version you have set as default. 这必须与您设置为默认版本的版本匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM