简体   繁体   中英

Rails doesn't complete installation on OS X Lion

I'm quite new to Ruby in general and especially RoR, so tell me if I need to add more information.

Upon running sudo gem install rails (after a long delay) I receive the following error message:

ERROR:  While executing gem ... (Gem::RemoteFetcher::UnknownHostError)
no such name (https://api.rubygems.org/quick/Marshal.4.8/mime-types-1.17.2.gemspec.rz)

I entered the link and it downloaded something, so I tried again - not entirely surprisingly, I got the same error.

I'm running OSX 10.7.5 and I've installed XCode 4.6.3 as well as the command line tools. I've installed Ruby 2.1.0 so I know I have that up to date. I thought the error might have something to do with sudo typically running whatever came with the machine, but if that's true, wouldn't it give me an error saying I needed a version of Ruby >= 1.9.3?

To be perfectly clear what I'm asking: why will Rails not install under the above conditions, and how can this be remedied?

Edit: I ran the command yet another time and this time it worked, and I don't know why it didn't before or what made it work now. As a note for anyone who should care, I do have RVM installed and used it to install Ruby.

OS X comes with ruby 1.8.x My guess is that you are still defaulting to that version and not the 2.1 you have installed. I would recommend installing RVM or equivalent so that you can shift from system 1.8.x to your 2.1 (or else as you can manage several versions of ruby and rails with RVM)

I would recommend against installing rails as root. I ran into this issue where

ruby -v

returned ruby 2.1.0 and

sudo ruby -v

returned ruby 1.9.1

Every time I tried to run

gem install rails

I kept getting errors as a result. I'm not familiar with Mac's package manager but this is what worked for me on ubuntu

sudo apt-get remove ruby1.9.1

then

sudo ruby -v

should return command not found. Then installing rails worked fine

gem install rails

These were the directions I followed. The main problem was I had already installed ruby prior to running(I think heroku toolbelt did it). https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm

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