OSX Sierra version 10.12.6
if you are getting error like
ERROR: Could not find a valid gem '<some package name>' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - SSL_connect retur
test your TLS v1.2 support
$ ruby -ropenssl -e 'puts "TLS v1.2 support: #{OpenSSL::SSL::SSLContext::METHODS.include?(:TLSv1_2)}"'
TLS v1.2 support: false
notice you're getting false
meaning not supported
$ brew install ruby
$ echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
$ export LDFLAGS="-L/usr/local/opt/ruby/lib"
$ export CPPFLAGS="-I/usr/local/opt/ruby/include"
$ export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"
$ source ~/.bash_profile
test your TLS v1.2 support again
$ ruby -ropenssl -e 'puts "TLS v1.2 support: #{OpenSSL::SSL::SSLContext::METHODS.include?(:TLSv1_2)}"'
-e:1: warning: constant OpenSSL::SSL::SSLContext::METHODS is deprecated
TLS v1.2 support: true
notice you're getting true
meaning it is supported