Ruby is an old Script language very like Python and Tcl. Some company still use it for old framework and kits, and in some case will have to stick with an old version of the script. I had 2.2.6 installed for this reason. Ruby is using gem for installing package, just like CPAN for Perl, Pip for Python, npm for Nodes. The gem installing used to be working fine for me. Recently when I started to try something new, I would need to install a new package, then I hit this "SSL Error When installing rubygems, Unable to pull data from 'https://rubygems.org/" issue. As usually, I searched for solution via Google, and started to take action as mentioned in this Stack Overflow post: https://stackoverflow.com/questions/19150017/ssl-error-when-installing-rubygems-unable-to-pull-data-from-https-rubygems-o.
I tried gem sources -r https://rubygems.org/
first (note the slash at the end is important, as the url has to match exactly with 'gem sources' command's output, otherwise it will do nothing), then run gem sources -a http://rubygems.org/
, but I was still seeing the SSL error, i.e. it is still taking the https protocol. Tried gem update --system
, nothing changed, same SSL error. Eventually, I went to RubyGems ssl-certificate-update page, and realized that I will have to manually update the certificate. I followed instruction here: https://bundler.io/v2.0/guides/rubygems_tls_ssl_troubleshooting_guide.html, run this curl -Lks 'https://git.io/rg-ssl' | ruby
just to confirm it is certificate issue. Note on Windows, I have to run this command from Cygwin console, otherwise the curl command outputs nothing. After replaced the certificate, now I don't see the SSl issue, instead I'm seeing a new issue: it cannot find any package from repository. Then I tried to run 'gem sources', and realized it shows empty! If I try gem sources -a command, it will complain the same, not able to find repository. This is the frustrate part started: I assume the gem sources -r screwed up something, so I tried to reinstall Ruby. However, no matter how, I just won't be able to get it back to normal. I tried to delete the old installation folder after an uninstall, tried to install to different location, tried to install a latest Ruby release, tried to search and delete all Ruby entry in Windows Registry table. But at the end, 'gem sources' still gives me an empty list.
That's the things I hate Windows, specially the Registry is huge and complex, and no easy way to search a key or value ( I mean with regular expression pattern matching). And I don't understand why an uninstall not able to clean up everything. I don't want to try the Windows Restore point. So I grabbed SystemInternals ProcMon to check why the Ruby Gem just keeps remember the source list even after a reinstall, and eventually found: there is a '.gemrc' file stored in my home folder, and that is the one gem used for the source list. Just delete it would fix all the headache.
This is the story I want to share, if any one encountering the same problem while fixing the SSL issue with Ruby gem.