简体   繁体   中英

Ruby version - Error installing Rails

I'm getting the next error installing RoR
How can I set the correct Ruby Version?

##@##: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 ... . 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.

Updating the system version of Ruby depends on your operating system, and usually lags behind the very latest version of Ruby. I've been using 2.0 for my latest project I launched last month. I doubt big OS vendors like Ubuntu or Apple are providing that version in their latest distribution. It's best that you manage your own Rubies whenever possible.

To install 1.9.3 you can run:

$ rvm install 1.9.3

then later

$ rvm use 1.9.3

You have :

@##:path$ ruby -v
.....

@##:path$ sudo gem install rails

...you said in your comment that :

$ sudo ruby -v

...gives you

ruby 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.

To install rails just type the following without sudo :

$ gem install rails

...it should works as you've a supported ruby version (ruby 2.0.0p247)

You can check Install Ruby on Rails · Ubuntu Linux instructions (Which I found useful) if you've more troubles.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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