R. Baku R. Baku - 5 months ago 41
Ruby Question

Can't install any RubyGems, invalid argument error when connecting to sources [gem 2.4.8]

I can't install any ruby gems on this Mac running OSX 10.11.

Here is what happens when I try to install a gem:


$ gem install rspec

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

Unable to download data from https://rubygems.org/ - Errno::EINVAL: Invalid argument - connect(2) for "rubygems.org" port 443 (https://rubygems.org/specs.4.8.gz)`


I thought it might be an ssl issue so I tried running


$ openssl s_client -showcerts -connect rubygems.org:https

connect: Invalid argument

connect:errno=22


Any ideas on what the problem is? Thank you for your time and help

Answer

There are [known] issues with SSL on rubygems.org, not on your machine. Explicitly set the source to be HTTP, not HTTPS:

gem install rspec --source http://rubygems.org

In your Gemfile (if any) you probably should set:

source 'http://rubygems.org'

as the very top line.