简体   繁体   中英

Can't update Ruby resulting in Rails error

I checked the list for http://railsapps.github.io/installrubyonrails-mac.html trying to reinstall Rails and have been trying to update it for the last 2+ hours.

This is what I get at the terminal:

Stevens-MBP:Desktop Steven$ rvm install ruby-2.3.1
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.11/x86_64/ruby-2.3.1.
Continuing with compilation. Please read 'rvm help mount' to get more    information on binary rubies.
Checking requirements for osx.
==> Upgrading 1 outdated package, with result:
automake 1.15
Error: You must `brew link autoconf` before automake can be installed
Requirements installation failed with status: 1.

Here is additional information:

Stevens-MBP:Desktop Steven$ rails -v
Rails is not currently installed on this system. To get the latest version,  simply type:

$ sudo gem install rails

You can then rerun your "rails" command.
Stevens-MBP:Desktop Steven$ ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin14.0]
Stevens-MBP:Desktop Steven$ 

When I type sudo gem install rails I get:

ERROR:  Error installing rails:
 activesupport requires Ruby version >= 2.2.2.

sudo gem install rails

Rule #1 when working with RVM (or rbenv) is do NOT use sudo except for multi-user installs (which are not encouraged by the maintainers).

By default, RVM and rbenv manage Rubies installed using them in a separate folder in your home directory where you already have full privileges to install/update/remove Rubies or gems. Use whichever manager you want to install/remove Ruby and set it as a default, then use gem install ... to install gems.

Using sudo changes your effective user to the sysadmin, which has a different idea where the RVM/rbenv managed Rubies and the associated gems live.

After issuing rvm install ruby-2.3.1 you should do

rvm use 2.3.1 --default

to tell RVM which Ruby you want to use.

rvm info will tell you what RVM knows about its world.

The error you get is probably because your vendor-installed version of Rails is out of date, and sudo is the root-cause of that occurring. Try gem install rails and you should be OK.

First upgrade ruby with rvm upgrade 2.1.2 2.3.1 That should do the trick if you have rvm installed correctly. Once it's done you can install rails with sudo gem install rails

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