31

I am trying to install the Bundler gem on my Mac. With the command: sudo gem install bundler I get the following error:

ERROR:  Could not find a valid gem 'bundler' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://s3.amazonaws.com/production.s3.rubygems.org/latest_specs.4.8.gz)

It clearly seems to be a server issue, but how do I go about solving this? gem update --system is currently up-to-date. Is there an alternative way to get Bundler?

Fisu
  • 3,294
  • 9
  • 39
  • 61
  • A lot of discussion on this tpoic here: http://stackoverflow.com/q/10246023/385532 - some of the other answers may help you. HTTPS failing is really common with rubygems :/ – Matt Oct 02 '13 at 08:07
  • If you want to setup a full fledged rails development environment, best use [this guide](http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#sec-up_and_running). This way you won't need to install bundler explicitly (it will get installed as a dependency). – Alexander Popov Oct 02 '13 at 08:11
  • I have this problem on travis – William Entriken May 02 '17 at 19:54

14 Answers14

40

Had the same issue and everything is described here: http://railsapps.github.io/openssl-certificate-verify-failed.html

tl;dr Recent versions of RVM, the Ruby Version Manager, include a utility to diagnose and resolve errors caused by outdated certificate files. See the article Installing Rails for instructions and advice. The RVM website explains how to install RVM.

If you’ve installed RVM, try this:

$ rvm -v
# rvm 1.19.1 (stable)
$ rvm osx-ssl-certs status all
# Certificates for...
$ rvm osx-ssl-certs update all
# Updating certificates...

That’s all that is needed to resolve the issue if you are using RVM (you must be using RVM version 1.19.1 or newer).

Yaron
  • 610
  • 6
  • 13
16

Windows users:

You can't run rvm command on Windows as you can see here, but you can fix the error without it. Just add a new source adress with http instead of https:

gem sources -a http://rubygems.org

Then you can run:

gem install bundler
Community
  • 1
  • 1
fabriciorissetto
  • 9,475
  • 5
  • 65
  • 73
  • 1
    Hmm, unmfortunately it doesn't work for me `ERROR: While executing gem ... (Gem::OperationNotSupportedError)` – Oak_3260548 Oct 12 '21 at 11:33
12

After looking at some of the answers to the Stack question @Matt referenced, although the error was different, one of the solutions also helped me for this problem.

In the home directory, create a file called .gemrc. Add :ssl_verify_mode: 0 to the file. Bundler then installs without issue.

This works for my situation as I'm behind a corporate firewall. However, this obviously opens up a security hole.

Community
  • 1
  • 1
Fisu
  • 3,294
  • 9
  • 39
  • 61
8

I had this same problem using Windows, and removing the security from the Hypertext Transfer Protocol solve it.

Paste in your terminal:

gem sources -r https://rubygems.org -a http://rubygems.org

Hope it will help! ★

David Bendahan
  • 4,104
  • 1
  • 24
  • 21
3

I faced the same problem installing bundler on windows 8.1. I solved it and installed bundler and other gems in the following way

  1. Go to https://gist.github.com/luislavena/f064211759ee0f806c88 and follow instructions.
  2. My gem version was 2.2.2. Update gem to 2.4.5 with the command:

    gem update --system

  3. Install gems:

    gem install bundler

    gem install rails

Hope that helps.

Placid
  • 1,400
  • 3
  • 22
  • 33
2

For those that arent using rvm, but are using homebrew:

brew tap raggi/ale
brew install openssl-osx-ca

This worked for me.

utx0_
  • 1,364
  • 14
  • 24
1

Below way solve my problem:

  1. In the home directory , find file .gemrc
  2. edit this file and find

    :sources: -https://rubygems.org/

  3. change https into http

  4. save the file and reopen the shell.
JaskeyLam
  • 15,405
  • 21
  • 114
  • 149
1

for those Chinese users, if you found rubygems.org is not available, change it to: gems.ruby-china.com: (对于中国用户,使用 gems.ruby-china.com 代替 rubygems.org)

$ gem install bundler
ERROR:  Could not find a valid gem 'bundler' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://api.rubygems.org/latest_specs.4.8.gz)

try this:

$ gem sources --add https://gems.ruby-china.com --remove https://rubygems.org/

then:

$ gem sources  -l
*** CURRENT SOURCES ***

https://gems.ruby-china.com/

then:

$ gem install bundler 

Fetching: bundler-1.12.5.gem (100%)
Successfully installed bundler-1.12.5
Parsing documentation for bundler-1.12.5
Installing ri documentation for bundler-1.12.5
Done installing documentation for bundler after 4 seconds
1 gem installed

My environment: rbenv, ruby 2.1.2, ubuntu 16.04 LTS

refer to: https://gems.ruby-china.com/

Siwei
  • 19,858
  • 7
  • 75
  • 95
0

Try gem source -c and then install bundler again that should solve the problem

  • 3
    Unfortunately after trying your method I still got the same error in trying to install Bundler. – Fisu Oct 03 '13 at 05:35
0

Finding this answer a couple of years later, I didn't feel comfortable with making my installation less secure, so I updated my Ruby installation to Ruby 2.2.2, which made the problem go away.

Mark Seemann
  • 225,310
  • 48
  • 427
  • 736
0
  1. Here is my error when I input the command sudo gem install bundler --no-ri --no-rdoc.

ERROR: Could not find a valid gem 'bundler' (>= 0), here is why: Unable to download data from https://rubygems.org/ - Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://api.rubygems.org/latest_specs.4.8.gz)

  1. And my solution is input the next command lines:

gem sources --remove https://rubygems.org/

gem sources --remove http://rubygems.org/

gem sources -l

and the output show:

*** CURRENT SOURCES *** http://rubygems.org/

  1. Then, try sudo gem install bundler --no-ri --no-rdoc again:

Fetching: bundler-1.11.2.gem (100%) Successfully installed bundler-1.11.2 1 gem installed

Bingo!!!

0

Bundler 2 requires at least Ruby 2.3.0 and RubyGems 2.5.0. You might get the following error when you try to install bundler for Ruby < 2.3:

COPY

  ERROR:  Error installing bundler:
  bundler requires Ruby version >= 2.3.0.

To fix this error upgrade your project's ruby version or install the last supported version of Bundler for Ruby < 2.3:

COPY gem install bundler -v '~>1'

Manish Shrivastava
  • 30,617
  • 13
  • 97
  • 101
0

Bundler 2 requires at least Ruby 2.3.0 and RubyGems 2.5.0.

You might get the following error when you try to install bundler for Ruby < 2.3:

ERROR:  Error installing bundler:
bundler requires Ruby version >= 2.3.0.

To fix this error upgrade your project's ruby version OR Install the last supported version of Bundler for Ruby < 2.3 by running only below command.

gem install bundler -v '~>1'
Manish Shrivastava
  • 30,617
  • 13
  • 97
  • 101
0

for Chinese users:

gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
gem sources --clear-all
gem sources --update
gem sources -l
Gavin Gao
  • 309
  • 3
  • 6