问题
I installed rvm and ruby successfully in a linux environment. When I try to install rail, that time I face following error:
$ gem install rails
/home/bathakarai/.rvm/rubies/ruby-1.9.3-p385/bin/gem:4: warning: Insecure world writable dir /home/bathakarai in PATH, mode 040777
ERROR: Could not find a valid gem 'rails' (>= 0) in any repository
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
Errno::EHOSTUNREACH: No route to host - connect(2) (http://rubygems.org/latest_specs.4.8.gz)
My gem version is
1.8.25
Rvm version is "rvm 1.18.19 (stable) by Wayne E. Seguin , Michal Papis [https://rvm.io/]".
Please help me by letting me know why this error occurs.
回答1:
You can use to install with below command
gem install rails --source http://rubygems.org
回答2:
Yes, Finally I got the result. It seems like some sort of proxy problem. I set the proxy using export "$HTTP_PROXY=IPAddress which is given in browser:portnumber". For any reference http://khylo.blogspot.in/2007/12/ruby-on-rails-headaches.html
回答3:
Try running
sudo gem install rails
This may overcome the permission problem you are having
You also look to be having an internet connectivity problem based on the error message.
回答4:
In my case the culprit was avast! Internet Security software on my MacBook Pro. I went to System Preferences, clicked on avast!, clicked on the lock to enable changes, and disabled the Web Shield and File System shield.
After that, I was able to install gems.
回答5:
I have struggled to install rails for two days (I've been getting almost the same error message, but, without that "Insecure world ..." line). And at last I did it using the script below (provided at RailsGirls):
bash < <(curl -sL https://raw.github.com/railsgirls/installation-scripts/master/rails-install-ubuntu.sh)
I don't know why it worked. Just leaving it here with the hope that it will be helpful for some other soul as well. ;P
来源:https://stackoverflow.com/questions/15492110/error-could-not-find-a-valid-gem-rails-0-in-any-repository