Dale Brown
Dale Brown

Reputation: 355

JSON gem install error: unable to download data

I'm using:

When testing in the Ruby environment and running the JSON gem install, I receive this error:

C:\RoW\Ruby200\devkit>gem install json --platform=ruby

ERROR:  Could not find a valid gem 'json' (>= 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://rubygems.org/latest_specs.4.8.gz)

Upvotes: 2

Views: 3547

Answers (2)

Fabrice31
Fabrice31

Reputation: 760

SSL error is due to a change in rubygems.org. You can see a solution here : https://gist.github.com/luislavena/f064211759ee0f806c88

You need to change your SSL certificate

Edit:

Manual solution to SSL issue

If you have read the above detail that describe the issue, thank you.

Now, you want to manually fix the issue with your installation.

Steps are simple:

Step 1: Obtain the new trust certificate
Step 2: Locate RubyGems certificate directory in your installation
Step 3: Copy new trust certificate
Step 4: Profit

Step 1: Obtain the new trust certificate

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.

Use the above link and place/save this file somewhere you can later find easily (eg. your Desktop).

IMPORTANT: File must have .pem as extension. Browsers like Chrome will try to save it as plain text file. Ensure you change the filename to have .pem in it after you have downloaded it. Step 2: Locate RubyGems certificate directory in your installation

In order for us copy this file, we need to know where to put it.

Depending on where you installed Ruby, the directory will be different.

Take for example the default installation of Ruby 2.1.5, placed in C:\Ruby21

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.

Step 4: Profit

There is actually no step 4. You should be able to install Ruby gems without issues now.

Upvotes: 2

Chris 99
Chris 99

Reputation: 1

If you have one [Ruby193 install folder with executables] in your C:drive, then you should change to that directory and execute the same command in the bin folder...

User@Computer-Name /c/Ruby193/bin ./gem install json --platform=ruby

$ ./gem install json --platform=ruby Fetching: json-1.8.1.gem (100%) Building native extensions. This could take a while... ERROR: Error installing json: ERROR: Failed to build gem native extension.

    c:/Ruby193/bin/ruby.exe extconf.rb

creating Makefile

make generating generator-i386-mingw32.def compiling generator.c generator.c:1:0: error: CPU you selected does not support x86-64 instruction set

generator.c:1:0: error: CPU you selected does not support x86-64 instruction set

make: *** [generator.o] Error 1

Gem files will remain installed in c:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8. 1 for inspection. Results logged to c:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/ge nerator/gem_make.out

Upvotes: 0

Related Questions