57

I'm attempting to follow the Hartl Rails Tutorial, and having trouble with the bundler gem.

When using the commands 'bundle install' or 'bundle update' I get the following output:

Fetching source index from https://rubygems.org/

Could not fetch specs from https://rubygems.org/

I've searched for this output, but did not find many related issues online.

Maybe I have another gem that is interrupting bundler? I have little experience with rails at this point.

    source 'https://rubygems.org'

gem 'rails', '3.2.12'

group :development do
  gem 'sqlite3', '1.3.5'
end


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '3.2.5'
  gem 'coffee-rails', '3.2.2'

  gem 'uglifier', '1.2.3'
end

gem 'jquery-rails', '2.0.2'

The solution for me was two parts: I changed https to http, and that temporarily solved the issue. The second issue was that I think I had a bad install of ruby 2.0.0 even though I was using a fresh install of ruby 1.9.3. So I reinstalled ruby 2.0.0, and I could use bundle install with https.

Steven
  • 571
  • 1
  • 5
  • 6
  • That means your ruby installation doesn't play with OpenSSL correctly. It's supposed to give a different kind of error, though, weird – enthrops Mar 04 '13 at 05:07
  • I did brew install openssl earlier today, could they have affected it? – Steven Mar 04 '13 at 05:11
  • I actually installed all of these from 'rvm requirements' "brew install autoconf automake apple-gcc42 libtool pkg-config openssl readline libyaml sqlite libxml2 libxslt libksba" I'm new to this type of environment, and not sure if any of those would affect this. – Steven Mar 04 '13 at 05:12
  • Well, this depends on lots of things, depending on whether you use system ruby, rbenv, or rvm. And then there are flags to go along with installing ruby, certificates, and lots of other stuff. And then ruby 2.0 handles OpenSSL differently, so unless you want to deal with all that, just go with 'http://' in the Gemfile, although it's not secure – enthrops Mar 04 '13 at 05:14
  • Ah, I did accidentally install ruby 2.0 today while installing RVM. I did a clean install of Mac OS 10.8.2, installed X-code, then installed homebrew, then RVM, then Ruby 2.0, then Ruby 1.9.3. Then gcc42, and the other packages like openssl through brew. But come to think of it, I think Ruby 2.0 did not properly install, so I will reinstall that... – Steven Mar 04 '13 at 05:16
  • I gave up on RVM some time ago and went with RBenv which is much simpler. When 2.0 came out I had to compile it linking with OpenSSL from homebrew, download a certificate from Mozilla and then set an environmental variable to point to it. That allows me to use https:// in the Gemfile. Not really sure how all that would go with RVM, these things are changing ALL the time – enthrops Mar 04 '13 at 05:20
  • If you decide to try out Rbenv, get [this plugin](https://github.com/sstephenson/ruby-build) to be able to install ruby versions with `rbenv install` and also don't forget to remove rvm, or they will conflict – enthrops Mar 04 '13 at 05:25

18 Answers18

70

Just in case none of the above satisfies the next intrepid explorer, I thought I'd drop here that after I spent 4 hours on this doing variants of the search that landed me here, I finally discovering that IPV6 was the culprit, after finding this specific thread on help.rubygems.org. Solution? this (Fedora, Linux):

sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1

set up a shell script to flip IPV6 on and off so I could run a command without it, and now everything runs peachy.

WebDragon
  • 876
  • 6
  • 12
  • 18
    Same exact frustrating issue (intermittent, too, this worked fine yesterday) encountered with macOS (Sierra, in my case). On a Mac, the command to switch ipv6 on and off is `sudo networksetup -setv6off 'Wi-Fi'` and to turn it back on is `sudo networksetup -setv6automatic 'Wi-Fi'`. (Substitute `Wi-Fi` for the name of your network interface in the Network preferences). Making this into a wrapper script for bundler is left as an exercise for the reader. WHY THE HECK do we still have these issues in 2019? Google Cloud Platform has the same issue. – XP84 Jan 30 '19 at 16:30
  • 5
    this deserves more upvotes. The solution that involves changing https to http is a security concern and should be avoided. – cyc115 Apr 26 '19 at 22:19
  • 3
    this might be sounding weird but this answer really does the job; I didn't want to believe but in my case IPv6 was the root cause of the issue. thanks – fycth Jul 01 '20 at 19:10
  • It must be: sysctl net.ipv6.conf.all.disable_ipv6 sysctl net.ipv6.conf.default.disable_ipv6..........Also this way not worked totally!! – Mohsen Abasi Jul 16 '22 at 08:02
  • I'm not sure what you mean, Mohsen. the -w switch is what writes the change, the =1 specifies the change is binary true, and sudo is sudo. what did you do differently and in what way is it not completely working? – WebDragon Jul 18 '22 at 17:28
27

I had the same issue. The only working solution I found was to force http instead of https in Gemfile:

source 'http://rubygems.org'
ldl
  • 503
  • 4
  • 6
  • This is not a viable solution, more of a hacky work around. The use of HTTPS is there to prevent MITM attacks so you know the gems you are downloading are legitimate from the source. Use with caution! – Dan Oct 14 '22 at 09:15
  • Did not help me – TwistedOwl Oct 21 '22 at 10:07
11

you can try the following, if in windows:

set HTTP_PROXY= <your proxy address without http://>

set HTTPS_PROXY=%HTTP_PROXY%

For eg:

HTTP_PROXY=mycompany.myproxy.com:8080

HTTPS_PROXY=%HTTP_PROXY%

Worked for me

Viktor
  • 2,623
  • 3
  • 19
  • 28
Dminds
  • 183
  • 2
  • 10
8

It can be temporary network issue as well. Try restarting network services using command

service network restart

If its *nix machine.

Aziz Zoaib
  • 661
  • 8
  • 21
5

I had the same issue using ruby-2.0.0-p247 on OS X 10.8.5.

Make sure the first line in Gemfile is using https://

source 'https://rubygems.org'

I reinstalled that version of ruby.

rvm reinstall ruby-2.0.0

Ruby was upgraded ruby-2.0.0-p598 (version depends on latest patch).

bundle then worked without error although all the gems were reinstalled.

mindriot
  • 14,149
  • 4
  • 29
  • 40
3

Mine was just a simple network issue, just restart pc / router

A. Askarov
  • 625
  • 7
  • 13
2

The other reason causing such that issues is the fact if you are behind proxy server. I describe here solution, maybe it will be usefull for someone else. :)

In case that you did not know Login/pass for yours proxy, and meet this issues you could firstly check if you need to (re)install anything, by command:

C:\...> bundle check
Resolving dependencies...
The Gemfile's dependencies are satisfied

If you get other respons then above, you could find properly gems in properly versions here (rubygems.org), then install it (from the directory with downloaded gem) by command:

gem install <gem-name> --locally 
Artur_PL
  • 57
  • 1
  • 7
2

Use wget to see if you can reach the domain

wget http://rubygems.org/latest_specs.4.8.gz

If this fails then try the following.

Edit your /etc/resolv.conf file and add these lines near the top to use Google's name servers

nameserver 8.8.8.8
nameserver 8.8.4.4
Justin Leveck
  • 2,308
  • 2
  • 20
  • 22
1

I had this issue while working in Cloud 9. After trying several 'bundle install' and sending an email to c9 support(no reply) I was able to get it working by killing all the processes and doing a hard-restart of the IDE.

Do this by clicking directly on the little bar-graphs at the top of the right-hand side that show CPU, Memory, Disk. Then click on the process list, select them all, and force kill. Then exit out of the process list. Click on the bar-graphs again, and this time click 'Restart'.

After this I was able to run bundle with no problems.

1

Either with http or https did not work.

After I disabled the IP v6, it worked

https://support.purevpn.com/how-to-disable-ipv6-linuxubuntu

0

Adding variable for proxy worked fine.

Additionally if you are using Bitnami redmine like me you can add that into setenv.bat then when you start command line with Bitnami Redmine short cut it will be automatically added to your environment. You can find this under Bitnami installation folder.

Heungwoo
  • 91
  • 1
  • 3
0

If you are using Cloud9, just restart (command R) and try again

0

Sometimes it happens due to proxy you are using. I tried to resolve this by using a connection without proxy and all worked perfectly fine.
Then try:

bundle update

And then go for

bundle install
0

For me, restarting the computer worked. I had already reinstalled ruby, updated bundler, removed 's' https:// but none of them worked!

0

A very simple solution I've used recently to overcome Bundler::HTTPError Could not fetch specs from https://rubygems.org/ which doesn't require you to disable IPV6 globally in your system:

  1. ping -4 rubygems.org - to get an IPV4 address
  2. Add the following line to your /etc/hosts file (use whatever IP address from the previous command output cause it might change):
    151.101.129.227 rubygems.org
    
zinovyev
  • 2,084
  • 1
  • 22
  • 32
0

I just had to restart my wifi and it started working.

Sunwoo Yang
  • 1,213
  • 2
  • 12
  • 22
-1

CHange your source form https to http after run

sudo bundle update sudo bundle install

Nicollas
  • 250
  • 2
  • 9
-1

In my case the source of the problem was VPN. Disconnecting from it helped to resolve the issue.

TwistedOwl
  • 1,195
  • 1
  • 17
  • 30