When I run bundle install for my Rails 3 project on Centos 5.5 it fails with an error:
Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3
read server certificate B: certificate verify failed
(https://bb-m.rubygems.org/gems/multi_json-1.3.2.gem)
An error occured while installing multi_json (1.3.2), and Bundler cannot continue.
Make sure that `gem install multi_json -v '1.3.2'` succeeds before bundling.
When I try to install the gem manually (by gem install multi_json -v '1.3.2') it works. The same problem occurs with several other gems. I use RVM (1.12.3), ruby 1.9.2, bundler 1.1.3.
How to fix it?
Update
Now that I've karma wh..err mined enough from this answer everyone should know that this should have been fixed.
re: via Ownatik again bundle install fails with SSL certificate verification error
gem update --system
My answer is still correct and left below for reference if that ends up not working for you.
Honestly the best temporary solution is to
[...] use the non-ssl version of rubygems in your gemfile as a temporary workaround.
via user Ownatik
what they mean is at the top of the Gemfile in your rails application directory change
source 'https://rubygems.org'
to
source 'http://rubygems.org'
note that the second version is http instead of https
Replace the ssl gem source with non-ssl as a temp solution:
gem sources -r https://rubygems.org/
gem sources -a http://rubygems.org/
The reason is old rubygems. You need to update system part using non ssl source first:
gem update --system --source http://rubygems.org/ (temporarily updating system part using non-ssl connection).
Now you're ready to use gem update.
If you're on a mac and use a recent version of RVM (~1.20), the following command worked for me.
rvm osx-ssl-certs update
This issue should now be fixed. Update rubygems (gem update --system), make sure openssl is at the latest version on your OS, or try these tips of it's still not working: http://railsapps.github.com/openssl-certificate-verify-failed.html
Temporary solution (as alluded to by Ownatik):
Create or modify a file called .gemrc in your home path, including the line :ssl_verify_mode: 0
This will prevent bundler from checking the SSL certificates of gems when it attempts to install them.
For *nix devices, 'home path' means ~/.gemrc. You can also create /etc/gemrc if you prefer. For Windows XP, 'home path' means c:\Documents and Settings\All Users\Application Data\gemrc. For Windows 7, C:\ProgramData\gemrc
On windows7 you can download the cacert.pem file from here and set the environementvariable SSL_CERT_FILE to the path where you store the certificate eg
SET SSL_CERT_FILE="C:\users\<username>\cacert.pem"
or you can set the variable in your script like this ENV['SSL_CERT_FILE']="C:/users/<username>/cacert.pem"
Replace <username> with you own username.
The real solution to this problem, if you are using RVM:
Update rubygems: gem update --system
Use RVM to refresh SSL certs: rvm osx-ssl-certs update all
Hat tip to this tip on the RailsApps project!
You can download a list of CA certificates from curl's website at http://curl.haxx.se/ca/cacert.pem
Then set the SSL_CERT_FILE environment variable to tell Ruby to use it. For example, in Linux:
$ SSL_CERT_FILE=~/cacert.pem bundle install
(Reference: https://gist.github.com/fnichol/867550)
For those of you that have ruby installed through RVM and want a quick fix (preferring not to read per Bruno's request) just try this:
rvm remove 1.9.x (or whatever version of ruby you are using)
rvm pkg install openssl
rvm install 1.9.2 --with-openssl-dir=$rvm_path/usr
For a more details, here is the link where I found the solution.
http://railsapps.github.com/openssl-certificate-verify-failed.html
BTW, I didn't have to touch my certificates on Ubuntu.
Best of all, this isn't a workaround. It will download gems through
SSL and fail if there if there is a problem like a man in the middle
attack which is much better than just turning off security.
This has been fixed
http://guides.rubygems.org/ssl-certificate-update/
Now that RubyGems 2.6.x has been released, you can manually update to this version.
Download https://rubygems.org/downloads/rubygems-update-2.6.7.gem
Please download the file in a directory that you can later point to (eg. the root of your harddrive C:)
Now, using your Command Prompt:
C:\>gem install --local C:\rubygems-update-2.6.7.gem
C:\>update_rubygems --no-ri --no-rdoc
After this, gem --version should report the new update version.
You can now safely uninstall rubygems-update gem:
C:\>gem uninstall rubygems-update -x
Simple copy paste instruction given here about .pem file
https://gist.github.com/luislavena/f064211759ee0f806c88
For certificate verification failed
If you've read the previous sections, you will know what this means (and shame > on you if you have not).
We need to download AddTrustExternalCARoot-2048.pem.
Open a Command Prompt and type in:
C:>gem which rubygems
C:/Ruby21/lib/ruby/2.1.0/rubygems.rb
Now, let's locate that directory. From within the same window, enter the path part up to the file extension, but using backslashes instead:
C:>start C:\Ruby21\lib\ruby\2.1.0\rubygems
This will open a Explorer window inside the directory we indicated.
Step 3: Copy new trust certificate
Now, locate ssl_certs directory and copy the .pem file we obtained from previous step inside.
It will be listed with other files like GeoTrustGlobalCA.pem.
same problem but with different gem here:
Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3
read server certificate B: certificate verify failed
(https://bb-m.rubygems.org/gems/builder-3.0.0.gem)
An error occured while installing builder (3.0.0), and Bundler cannot continue.
Make sure that `gem install builder -v '3.0.0'` succeeds before bundling.
temporarily solution: gem install builder -v '3.0.0' makes it possible to continue bundle install
The simplest solution:
rvm pkg install openssl
rvm reinstall all --force
Voila!
This is How you fix this problem on Windows:
download .perm file then set the SSL_CERT_FILE in command prompt
https://gist.github.com/fnichol/867550
My permanent fix for Windows:
Download the CACert , save as C:\ruby\ssl_certs\GlobalSignRootCA.pem from http://guides.rubygems.org/ssl-certificate-update/
Create system variable named "SSL_CERT_FILE", set to C:\ruby\ssl_certs\GlobalSignRootCA.pem.
Try again: gem install bundler:
C:\gem sources
*** CURRENT SOURCES ***
https://rubygems.org/
C:\gem install bundler
Fetching: bundler-1.13.5.gem (100%)
Successfully installed bundler-1.13.5
1 gem installed
I get a slightly different error, though perhaps related, on Ubuntu 12.04:
Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=unknown state: sslv3 alert handshake failure (https://d2chzxaqi4y7f8.cloudfront.net/gems/activesupport-3.2.3.gem)
An error occured while installing activesupport (3.2.3), and Bundler cannot continue.
Make sure that `gem install activesupport -v '3.2.3'` succeeds before bundling.
It happens when I run bundle install with source 'https://rubygems.org' in a Gemfile.
This is an issue with OpenSSL on Ubuntu 12.04. See Rubygems issue #319.
To fix this, run apt-get update && apt-get upgrade on Ubuntu 12.04 to upgrade your OpenSSL.
I was able to track this down to the fact that the binaries that rvm downloads do not play nice with OS X's OpenSSL, which is old and is no longer used by the OS.
The solution for me was to force compilation when installing Ruby via rvm:
rvm reinstall --disable-binary 2.2
Thx to #Alexander.Iljushkin for:
gem update --system --source http://rubygems.org/
After that bundler still failed and the solution to that was:
gem install bundler
I was getting a similar error. Here is how I solved this: In your path directory, check for Gemfile. Edit the source in the gemfile to http instead of https and save it. This might install the bundler without the SSL certificate issue.l
For Windows machine, check your gem version with
gem --version
Then update your gem as follow:
Running 1.8.x: download 1.8.30
Running 2.0.x: download 2.0.15
Running 2.2.x: download 2.2.3
Please download the file in a directory that you can later point to (eg. the root of your hard drive C:)
Now, using your Command Prompt:
C:\>gem install --local C:\rubygems-update-1.8.30.gem
C:\>update_rubygems --no-ri --no-rdoc
Now, bundle install will success without SSL certificate verification error.
More detailed instruction is here
This worked for me:
download latest gem at https://rubygems.org/pages/download
install the gem with gem install --local [path to downloaded gem file]
update the gems with update_rubygems
check that you're on the latest gem version with gem --version
I had to reinstall openssl:
brew uninstall --force openssl
brew install openssl
I was just recently faced with this issue and followed the steps outlined here. There might be a chance that you are not pointing to the right OpenSSL certificate. After running:
rvm osx-ssl-certs status all
rvm osx-ssl-certs update all
and
export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
the bundle complete ran!
Download rubygems-update-2.6.7.gem .
Now, using your Command Prompt:
C:\>gem install --local C:\rubygems-update-2.6.7.gem
C:\>update_rubygems --no-ri --no-rdoc
After this, gem --version should report the new update version.
You can now safely uninstall rubygems-update gem:
C:\>gem uninstall rubygems-update -x
Removing update_rubygems
Successfully uninstalled rubygems-update-2.6.7
To note, if you're grabbing gems from a source which SSL cert is trusted by an internal certificate authority (or you are connecting to an external source through a company web proxy with SSL inspection), point your SSL_CERT_FILE env variable to your certificate chain. This most likely just requires exporting your root certificate from your certificate store (System Keychain on macOS) to an accessible location from your shell i.e.:
export SSL_CERT_FILE=~/RootCert.pem
If you're using rails-assets
If you were using https://rails-assets.org/ to manage your assets, no answers will help you. Even converting to http won't help.
The simplest fix is using this source instead, http://insecure.rails-assets.org. This has been mentioned in their homepage.
The only thing that worked for me on legacy windows system and ruby 1.9 version is downloading cacert file from
http://guides.rubygems.org/ssl-certificate-update/
And then running below command before running bundle install
bundle config --global ssl_ca_cert /path/to/file.pem
Related
I'm trying to establish an ssh tunnel to a remote server as described here: SSH from Heroku into remote server with Mysql Db
But I'm hung up just simply trying to download the gems. I added:
# file: Gemfile
...
gem 'net-ssh-gateway', '~> 1.2.0'
but when I do bundle install (or even just gem install net-ssh on the command line), I get:
ERROR: Could not find a valid gem 'net-ssh' (>= 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://api.rubygems.org/latest_specs.4.8.gz)
As per the README for net-ssh (https://github.com/net-ssh/net-ssh), I checked my OpenSSL bindings for Ruby -- they look okay:
$ ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
OpenSSL 1.0.1j 15 Oct 2014
I'm not sure if this is related, but when I tried to download the .pem file for a high security download of the gemfile:
$ curl -O https://raw.github.com/net-ssh/net-ssh/master/gem-public_cert.pem
... it didn't download a .pem file, and visiting the URL directly result in 'not found'.
Other info:
$ rake about
About your application's environment
Ruby version 2.1.4-p265 (x86_64-darwin14.0)
RubyGems version 2.2.2
Rack version 1.5
Rails version 4.1.7
So for right now, I'm stuck. Does anyone recognize this problem?
This helped in my case, when I had a problem with certificate:
gem sources -r https://rubygems.org
gem sources -a http://rubygems.org
gem update --system
gem sources -r http://rubygems.org
gem sources -a https://rubygems.org
Despite #the Tin Man's helpful answer, my problem was that I didn't have certificates set up in a place that OpenSSL could find them.
Following suggestions(s) in SSL Error When installing rubygems, Unable to pull data from 'https://rubygems.org/:
An inferior workaround
One can work around this by changing the first line of Gemfile from
source 'https://rubygems.org'
to the non-https form:
source 'http://rubygems.org'
and then do the usual bundle install. Afterwards, you should restore the first line of your Gemfile to use the https form. This is generally considered a security risk.
What's more, you haven't really addressed the real problem that you lack valid certificates and you will run into trouble if your application calls uses OpenSSL (e.g. net-ssh).
A better fix
See SSL Error When installing rubygems, Unable to pull data from 'https://rubygems.org/. For OS X users, we ask Ruby to tell us where it's looking for the certificates file, and then use security find-certificate to populate the certificates file:
$ cert_file=$(ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE')
$ echo $cert_file
$ security find-certificate -a -p /Library/Keychains/System.keychain > "$cert_file"
$ security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain >> "$cert_file"
After I did this, I was able to call bundle install without an error.
hey everyone follow this link so you wont have to manual install everytime.
This says that the problem is from rubygems' change of ssl certasdaasdlashjd blah blah. NVM the link explains it best :p
I get the following error when attempting to run cap production deploy.
DEBUG [dc362284] Bundler::GemNotFound: Could not find json-1.8.1.gem for installation
DEBUG [dc362284] An error occurred while installing json (1.8.1), and Bundler cannot continue.
DEBUG [dc362284] Make sure that `gem install json -v '1.8.1'` succeeds before bundling.
It may be important to note that this deployment was working, than I upgraded to Ruby 2.1.0 to remove an encoding error. I upgraded locally which worked fine. I ran rvm install 2.1.0 and rvm use 2.1.0 then changed my .ruby-version file to reflect this Ruby upgrade.
The bundle install command works locally, but produces the same above error when I ssh onto the destination server and run this command.
If I run gem list I can see this in the list of gems.
...
jquery-rails (3.0.4)
json (1.8.1)
less (2.3.2)
...
If I try the recommended solution gem install json -v '1.8.1' Locally and on the destination server I get the following output:
Building native extensions. This could take a while...
Successfully installed json-1.8.1
Parsing documentation for json-1.8.1
Done installing documentation for json after 0 seconds
1 gem installed
So it appears the gem is installed, right? Why is this happening? How can I solve this? Any help would be greatly appreciated.
$ bundle update json
$ bundle install
So after a half day on this and almost immediately after posting my question I found the answer. Bundler 1.5.0 has a bug where it doesn't recognize default gems as referenced here
The solution was to update to bundler 1.5.1 using gem install bundler -v '= 1.5.1'
Run this command then everything will be ok
sudo apt-get install libgmp-dev
if you are in MacOS Sierra and your ruby version is 2.4.0.The ruby version is not compatible with json 1.8.3.
You can try add this line in your Gemfile:
gem 'json', github: 'flori/json', branch: 'v1.8'
This works for me!
To solve this problem, simply run:
bundle update
It will update the version of your bundler. Then run:
bundle install
Your problem will get solve. Solution is well explained here.
I found the solution here. There is a problem with json version 1.8.1 and ruby 2.2.3, so install json 1.8.3 version.
gem install json -v1.8.3
You should try
$ sudo gem install json -v '1.8.2'
in my case (Ubuntu 14.04) that didn't work directly and I had to do this:
$ sudo apt-get install ruby-dev
and then I could install the gem and continue. Had one more problem that was fixed by:
$ sudo apt-get install libsqlite3-dev
Hoping helps.
If the recommended answer didn't help because you are already using a newer version of bundler. Try the solution that worked for me.
Delete everything inside your vendor folder.
Add a line to your gemfile
gem 'json', '1.8.0'
Then run - bundle update json.
It seems to be an issue with 1.8.1 so going back to 1.8.0 did the trick for me.
I ran into this error while trying to get a project to run on my local dev box (OSX 10.6), using Sinatra and Postgresql (through activerecord), running on an rvm'd ruby 2.1. I found my answer here: https://github.com/wayneeseguin/rvm/issues/2511
My exact problem (after the first block of log entries):
I also get an error when trying to build native extensions for gems
The answer:
rvm reinstall 2.1.0 --disable-binary
The explanation:
OSX does not have a package manager so all libraries have to be installed manually by user, this makes it virtually impossible to link the binary dynamically, and as you can see there are problems with the (pseudo)statically linked binary.
For the sake of completeness, I had first forgotten to update rvm (rvm get head), which yielded some other errors, but still needed the --disable-binary flag once I had done so.
bundle update json. Helped to get through.
When I tried to install the json gem using gem install json separate from just using bundle install I got ERROR: Failed to build gem native extension., looking that up I found using
apt-get install ruby-dev
did the trick
For OS X make sure you have coreutils
$ brew install coreutils
$ bundle
This appears to be a bug in Bundler not recognizing the default gems installed along with ruby 2.x. I still experienced the problem even with the latest version of bundler (1.5.3).
One solution is to simply delete json-1.8.1.gemspec from the default gemspec directory.
rm ~/.rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/specifications/default/json-1.8.1.gemspec
After doing this, bundler should have no problem locating the gem. Note that I am using chruby. If you're using some other ruby manager, you'll have to update your path accordingly.
I was missing C headers solution was to download it for Xcode, this is the best way.
xcode-select --install
Hope it helps.
Bundle was failing to install json -v '1.8.1' and deleting my Gemfile.lock and running bundle again solved this issue for me.
I installed the latest version of json:
gem install json
Then deleted the line json(1.8.1) from the Gemfile.lock and did a
bundle install
And then the Gemfile.lock file uses json(1.8.3) without erros
Switch ruby version from 1.9 to 2.2 with rvm did the job for me
For me, some of the answers mentioned earlier were helpful from understanding point of view, but those didn't solve my problem.
So this is what I did to solve issue.
Modified gemfile.lock to update json (2.0.2) (Earlier, it was 1.8.3)
Check the Bundler version installed (Bundler -v command). I had version 1.12.5 installed
Install bundler version 1.11.2 (using gem install bundler -v '1.11.2')
Then run bundle install
For macOS Sierra:
I ran into this error When i used bundler(v1.15.3) in Rails(v4.2) project.
The solution for me is gem uninstall bundler -v '1.15.3' and gem install bundler -v '1.14.6'.
I'm getting this error when I run bundle install:
Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most likely
your system doesn't have the CA certificates needed for verification. For
information about OpenSSL certificates, see bit.ly/ruby-ssl. To connect without using
SSL, edit your Gemfile sources and change 'https' to 'http'.
However, it is only happening to one of my projects, and seems to be happening to only me. Also, I can get around it by running bundle update, where I don't get that error, and I can get up a running after that.
Is there something that isn't tracked in the project (that is only on my machine) that I have misconfigured?
I had this problem on Mac OS X Yosemite with ruby 2.3.1.
I fixed the problem by downloading http://curl.haxx.se/ca/cacert.pem to
/usr/local/etc/openssl/
and adding this line export SSL_CERT_FILE=/usr/local/etc/openssl/cacert.pem to .bash_profile
Credit to Can't run Ruby 2.2.3 with RVM on OSX but it was hard to google the right answer, so added to this page.
The solution for me on OS X 10.9.5 was to sudo rvm osx-ssl-certs update all.
Source: http://jacopretorius.net/2013/10/could-not-verify-the-ssl-certificate-for-rubygems.html
Running gem update --system worked for me
For linux users, simply install the package: ca-certificates
Since I am using rbenv instead of rvm, I wasn't able to do most of the solutions online.
I was able to fix the issue by uninstalling and reinstalling openssl
All is well, but I am not exactly sure why.
Upgrading openssl should fix the issue.(if it's MacOSX)
brew upgrade openssl
Using OSX 10.14.6 and Rails 6 this worked for me:
rvm osx-ssl-certs update
Maybe this method will be useful
1.Switch source to https://gems.ruby-china.org/
$ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
2.Check current source
$ gem sources -l
*** CURRENT SOURCES ***
https://gems.ruby-china.org
3.Mirror gem source
$ bundle config mirror.https://rubygems.org https://gems.ruby-china.org
Through these methods, you will not need to change Gemfile souce.
Hope this method will be useful for you.
I have problem with installing Rails 4. Hope you could help!
demo
$ rails -v
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
demo
$ sudo gem install rails
WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.
To proceed, enter your password, or type Ctrl-C to abort.
Password:
ERROR: Could not find a valid gem 'rails' (>= 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)
The Best Solution for installing Rails is by Using Ruby Version Manager(RVM)
run curl -L https://get.rvm.io | bash -s stable to install RVM and the Install Ruby Using RVM by this Command rvm install 2.0.0 then Install Rails from this command
gem install rails -v 4.0.0
You can good to go then.
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).
I am behind a firewall with internet blocker installed. I have power user previlage so I was able to install from git etc. But I am facing this only when I try installing 'gem'. Here is what I get, I think it says it recieved some error instead of a gzip.
Is there any config that I need to change? or any port or anything?? does it use ftp???
Please help..
[root#max-desktop max # gem install mongrel
ERROR: While executing gem ... (Zlib::GzipFile::Error)
not in gzip format
Check out the Rubygems page for Mongrel, where there is a download link.
$ wget http://rubygems.org/downloads/mongrel-1.1.5.gem
$ sudo gem install mongrel-1.1.5.gem
As a reminder, Mongrel has runtime dependencies that need to be installed first (you can use these same steps).
no idea, but maybe try upgrading rubygems?
sudo gem update --system