简体   繁体   English

Ruby版本-安装Rails时出错

[英]Ruby version - Error installing Rails

I'm getting the next error installing RoR 我在安装RoR时遇到下一个错误
How can I set the correct Ruby Version? 如何设置正确的Ruby版本?

##@##:path$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
##@##:path$ sudo gem install rails
ERROR:  Error installing rails:
    activesupport requires Ruby version >= 1.9.3.
##@##:path$ 

You shouldn't have to use sudo with gem install ... . 你不应该在gem install ...使用sudo gem install ... That's what's causing the mismatch between Ruby versions, since root is using the default installed Ruby, whereas your own account is using RVM's installed version. 这就是造成Ruby版本不匹配的原因,因为root使用的是默认安装的Ruby,而你自己的帐户正在使用RVM的安装版本。

Updating the system version of Ruby depends on your operating system, and usually lags behind the very latest version of Ruby. 更新Ruby的系统版本取决于您的操作系统,并且通常落后于最新版本的Ruby。 I've been using 2.0 for my latest project I launched last month. 我上个月启动的最新项目一直使用2.0。 I doubt big OS vendors like Ubuntu or Apple are providing that version in their latest distribution. 我怀疑像Ubuntu或Apple这样的大型OS供应商会在其最新发行版中提供该版本。 It's best that you manage your own Rubies whenever possible. 最好尽可能管理自己的红宝石。

To install 1.9.3 you can run: 要安装1.9.3,您可以运行:

$ rvm install 1.9.3

then later 然后

$ rvm use 1.9.3

You have : 你有 :

@##:path$ ruby -v @ ##:路径$ ruby​​ -v
..... .....

@##:path$ sudo gem install rails @ ##:path $ sudo gem install rails

...you said in your comment that : 你在评论中说:

$ sudo ruby -v $ sudo ruby​​ -v

...gives you ...给你

ruby 1.8.7 红宝石1.8.7

To resolve this problem you shouldn't use sudo , as it tries to install using root session with 1.8.7 ruby version which is not supported. 要解决此问题,您不应该使用sudo ,因为它尝试使用不支持的1.8.7 ruby​​版本的根会话进行安装。

To install rails just type the following without sudo : 要安装rails,只需键入以下内容而不使用sudo

$ gem install rails $ gem install rails

...it should works as you've a supported ruby version (ruby 2.0.0p247) ...它应该可以在您支持的ruby版本(ruby 2.0.0p247)下使用

You can check Install Ruby on Rails · Ubuntu Linux instructions (Which I found useful) if you've more troubles. 如果您遇到更多麻烦,可以查看安装Ruby on Rails·Ubuntu Linux说明(我发现它很有用)。

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

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