0

Recently I have needed to install pod file. I have tried by

$ sudo gem install cocoapods

but after several seconds after entering password, I got bellow error:

ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:

Unable to download data from http://rubygems.org/ - Errno::EHOSTUNREACH: No route to host - connect(2) (http://rubygems.org/latest_specs.4.8.gz)

I searched this error, I found some questions similar, such as Stack question but none of solution resolved my problem. If there is any other way to try, please let me know.

Community
  • 1
  • 1
Fa.Shapouri
  • 988
  • 2
  • 12
  • 30
  • This seems to not specifically be a problem with cocoapods, but rather with your inability to get data from RubyGems. I think that you'd fail trying to install other gems as well. [this](http://stackoverflow.com/questions/19150017/ssl-error-when-installing-rubygems-unable-to-pull-data-from-https-rubygems-o/29638157#29638157) or [this](http://stackoverflow.com/questions/19150017/ssl-error-when-installing-rubygems-unable-to-pull-data-from-https-rubygems-o/29638157#29638157) answer may be helpful. – max pleaner Jun 24 '16 at 19:54
  • Try other gems, such as `gem update --system` which will try to update the RubyGems software (and might fail with a permissions error). If it can't find the server then it's probably a network configuration problem, or the server is down. If it's the server it generally comes back up quickly. If it's the network then you'll have to try to diagnose the problem. – the Tin Man Jun 24 '16 at 20:12
  • @theTinMan I am strongly sure there is not any problem with network. It is result of command: `gem update --system` **Updating rubygems-update Fetching: rubygems-update-2.6.6.gem (100%) ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.** – Fa.Shapouri Jun 25 '16 at 16:30
  • @maxpleaner You right! I could not install other gems. The both links you addressed are same. – Fa.Shapouri Jun 25 '16 at 17:40

2 Answers2

2

I fixed this problem by changing my network to guest network. My main network has proxy authentication that prevented me from downloading the ruby from repo.

Steps to follow:

1.Switch to a different network

2. In terminal"sudo gem install cocoapods"

3.Close and restart terminal

4. Do "pod install"
sachin
  • 481
  • 1
  • 6
  • 7
0

The problem is fixed. The only change I have made on my system is installing the last stable version of node. Because I am not expert I can not explain how it solved.

Fa.Shapouri
  • 988
  • 2
  • 12
  • 30