1

I'm running macOS Monterey on an M1 Pro. I've installed rvm with Ruby 3.0.0 and 2.7.2.

➜  ~ rvm list
=* ruby-2.7.3 [ arm64 ]
   ruby-3.0.0 [ arm64 ]

# => - current
# =* - current && default
#  * - default

I can install gems without any issues when using Ruby 3.0.0. However, when I attempt to install gems using 2.7.3 - I start hitting problems.

➜  ~ gem install bundler -V --debug
NOTE:  Debugging mode prints all exceptions even when rescued
Exception `SocketError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:960 - getaddrinfo: Invalid value for ai_flags
Exception `SocketError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:962 - Failed to open TCP connection to rubygems.org:443 (getaddrinfo: Invalid value for ai_flags)
Exception `SocketError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:1025 - Failed to open TCP connection to rubygems.org:443 (getaddrinfo: Invalid value for ai_flags)
Exception `Gem::RemoteFetcher::UnknownHostError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/rubygems/remote_fetcher.rb:272 - no such name (https://rubygems.org/api/v1/dependencies)
Exception `Errno::EEXIST' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/fileutils.rb:250 - File exists @ dir_s_mkdir - /Users/cclarke/.gem/specs/rubygems.org%443
Exception `SocketError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:960 - getaddrinfo: Invalid value for ai_flags
Exception `SocketError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:962 - Failed to open TCP connection to rubygems.org:443 (getaddrinfo: Invalid value for ai_flags)
Exception `SocketError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:1025 - Failed to open TCP connection to rubygems.org:443 (getaddrinfo: Invalid value for ai_flags)
Exception `Gem::RemoteFetcher::UnknownHostError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/rubygems/remote_fetcher.rb:272 - no such name (https://rubygems.org/prerelease_specs.4.8.gz)
Exception `Errno::EEXIST' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/fileutils.rb:250 - File exists @ dir_s_mkdir - /Users/cclarke/.gem/specs/rubygems.org%443
Exception `SocketError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:960 - getaddrinfo: Invalid value for ai_flags
Exception `SocketError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:962 - Failed to open TCP connection to rubygems.org:443 (getaddrinfo: Invalid value for ai_flags)
Exception `SocketError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:1025 - Failed to open TCP connection to rubygems.org:443 (getaddrinfo: Invalid value for ai_flags)
Exception `Gem::RemoteFetcher::UnknownHostError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/rubygems/remote_fetcher.rb:272 - no such name (https://rubygems.org/specs.4.8.gz)
Exception `Gem::RemoteFetcher::UnknownHostError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/rubygems/spec_fetcher.rb:256 - no such name (https://rubygems.org/specs.4.8.gz)
Exception `Gem::UnsatisfiableDependencyError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/rubygems/resolver.rb:235 - Unable to resolve dependency: user requested 'bundler (>= 0)'
ERROR:  Could not find a valid gem 'bundler' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - no such name (https://rubygems.org/specs.4.8.gz)
Exception `Errno::EEXIST' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/fileutils.rb:250 - File exists @ dir_s_mkdir - /Users/cclarke/.gem/specs/rubygems.org%443
Exception `Errno::ENOENT' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/rubygems/remote_fetcher.rb:297 - No such file or directory @ rb_file_s_stat - /Users/cclarke/.gem/specs/rubygems.org%443/latest_specs.4.8
Exception `SocketError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:960 - getaddrinfo: Invalid value for ai_flags
Exception `SocketError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:962 - Failed to open TCP connection to rubygems.org:443 (getaddrinfo: Invalid value for ai_flags)
Exception `SocketError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:1025 - Failed to open TCP connection to rubygems.org:443 (getaddrinfo: Invalid value for ai_flags)
Exception `Gem::RemoteFetcher::UnknownHostError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/rubygems/remote_fetcher.rb:272 - no such name (https://rubygems.org/latest_specs.4.8.gz)
Exception `Gem::RemoteFetcher::UnknownHostError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/rubygems/spec_fetcher.rb:256 - no such name (https://rubygems.org/latest_specs.4.8.gz)
Exception `Errno::EEXIST' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/fileutils.rb:250 - File exists @ dir_s_mkdir - /Users/cclarke/.gem/specs/rubygems.org%443
Exception `SocketError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:960 - getaddrinfo: Invalid value for ai_flags
Exception `SocketError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:962 - Failed to open TCP connection to rubygems.org:443 (getaddrinfo: Invalid value for ai_flags)
Exception `SocketError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:1025 - Failed to open TCP connection to rubygems.org:443 (getaddrinfo: Invalid value for ai_flags)
Exception `Gem::RemoteFetcher::UnknownHostError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/rubygems/remote_fetcher.rb:272 - no such name (https://rubygems.org/prerelease_specs.4.8.gz)
Exception `Gem::RemoteFetcher::UnknownHostError' at /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/rubygems/spec_fetcher.rb:256 - no such name (https://rubygems.org/prerelease_specs.4.8.gz)

I've tried installing Ruby 2.7.2 in 2 ways but the problem still persists.

  • rvm install 2.7.2 (Installs fine)
  • Using this GitHub link

I think perhaps, it's the problem is with openssh but I cannot be sure. Why it can't open a TCP connection I with ruby gems I can't figure. If anyone has any insight I'd be very grateful.

Kind regards, Christian

~edit. My Gem sources are correctly set for 2.7.3 as they are for 3.0.0. Which works fine.

➜  ~ gem sources
*** CURRENT SOURCES ***

https://rubygems.org/

I ran curl from the rubygems.org site

➜  ~ curl -Lks 'https://git.io/rg-ssl' | ruby
Here's your Ruby and OpenSSL environment:

Ruby:           2.7.3p183 (2021-04-05 revision 6847ee089d7655b2a0eea4fee3133aeacd4cc7cc) [arm64-darwin21]
RubyGems:       3.1.6
Bundler:        2.1.4
Compiled with:  OpenSSL 1.1.1m  14 Dec 2021
Loaded version: OpenSSL 1.1.1m  14 Dec 2021
SSL_CERT_FILE:  /opt/homebrew/etc/openssl@1.1/cert.pem
SSL_CERT_DIR:   /opt/homebrew/etc/openssl@1.1/certs

With that out of the way, let's see if you can connect to rubygems.org...

Bundler connection to rubygems.org:       failed  ❌  (Failed to open TCP connection to rubygems.org:443 (getaddrinfo: Invalid value for ai_flags))
RubyGems connection to rubygems.org:      failed  ❌  (no such name (https://rubygems.org))
Ruby net/http connection to rubygems.org: failed  ❌

Unfortunately, this Ruby can't connect to rubygems.org. 
Even worse, we're not sure why. 

Here's the full error information:
SocketError: Failed to open TCP connection to rubygems.org:443 (getaddrinfo: Invalid value for ai_flags)
  /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:960:in `initialize'
  /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:960:in `open'
  /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:960:in `block in connect'
  /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/timeout.rb:95:in `block in timeout'
  /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/timeout.rb:105:in `timeout'
  /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:958:in `connect'
  /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:943:in `do_start'
  /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:938:in `start'
  -:101:in `<main>'

You might have more luck using Mislav's SSL doctor.rb script. You can get it here:
https://github.com/mislav/ssl-tools/blob/8b3dec4/doctor.rb
Read more about the script and how to use it in this blog post:
https://mislav.net/2013/07/ruby-openssl/
Traceback (most recent call last):
    8: from -:101:in `<main>'
    7: from /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:938:in `start'
    6: from /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:943:in `do_start'
    5: from /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:958:in `connect'
    4: from /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/timeout.rb:105:in `timeout'
    3: from /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/timeout.rb:95:in `block in timeout'
    2: from /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:960:in `block in connect'
    1: from /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:960:in `open'
/Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:960:in `initialize': getaddrinfo: Invalid value for ai_flags (SocketError)
    8: from -:101:in `<main>'
    7: from /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:938:in `start'
    6: from /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:943:in `do_start'
    5: from /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:958:in `connect'
    4: from /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/timeout.rb:105:in `timeout'
    3: from /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/timeout.rb:95:in `block in timeout'
    2: from /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:960:in `block in connect'
    1: from /Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:960:in `open'
/Users/cclarke/.rvm/rubies/ruby-2.7.3/lib/ruby/2.7.0/net/http.rb:960:in `initialize': Failed to open TCP connection to rubygems.org:443 (getaddrinfo: Invalid value for ai_flags) (SocketError)

~Edit. I couldn't figure this out. So, in the end I followed the advice in this post How to run the Homebrew installer under Rosetta 2 on M1 Macbook. For Ruby 3 I use native Arm. For Ruby 2.7.5 I use Rosetta2. Perhaps, not natively running Arm .. but at least it's working.

Christian Clarke
  • 841
  • 1
  • 9
  • 9

0 Answers0