ruby-install: Unable to install any Ruby versions after updating to macOS 12.6 on Apple Silicon
I updated to macOS 12.6 on 3 of my Macs: 2 of them Intel, and one of them Apple Silicon (M1 MacBook Air, 2020).
I am able to install Ruby 2.7.6 and 3.1.2 with ruby-install
on the Intel machines, but I canโt anymore on the M1 Air. It fails with ld: symbol(s) not found for architecture arm64
. Here is an excerpt from the end:
linking shared-object -test-/arith_seq/extract.bundle
Undefined symbols for architecture arm64:
"_rb_arithmetic_sequence_extract", referenced from:
_arith_seq_s_extract in extract.o
"_rb_ary_new_capa", referenced from:
_arith_seq_s_extract in extract.o
"_rb_ary_store", referenced from:
_arith_seq_s_extract in extract.o
"_rb_define_singleton_method", referenced from:
_Init_extract in extract.o
"_rb_path2class", referenced from:
_Init_extract in extract.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../../../../.ext/arm64-darwin21/-test-/arith_seq/extract.bundle] Error 1
make[1]: *** [ext/-test-/arith_seq/extract/all] Error 2
make: *** [build-ext] Error 2
!!! Compiling ruby 3.1.2 failed!
Iโve also attached the full log.
So then I tried compiling Ruby manually, and it failed after the first make
with the same error:
brew install wget
cd ~/src
wget https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.2.tar.xz
tar -xzvf ruby-3.1.2.tar.xz
cd ruby-3.1.2
./configure --with-opt-dir="$(brew --prefix openssl@1.1):$(brew --prefix readline):$(brew --prefix libyaml):$(brew --prefix gdbm)"
make
I even reset my entire dev setup (uninstalled Homebrew, removed the command line tools, removed all Ruby-related folders, etc.), and reinstalled everything from scratch.
So then I tried rbenv, and it worked just fine. Any ideas what rbenv/ruby-build might be doing differently?
Could it be something with the ./configure
options?
So then I tried installing 2.6.10 on my Intel machines, and it failed on my iMac with ruby-install
, but it worked with rbenv
. However, it failed with rbenv
on Apple Silicon. To make things more confusing, it worked on my Intel MacBook Air with both ruby-install
and rbenv
! The difference is that the iMac used to be on macOS 12.5.1, and the Intel Air was upgraded to Monterey from Big Sur.
I know this used to work before, so something must have changed with macOS 12.6.
Interestingly, 2.6.9 works on the Intel iMac (the one where 2.6.10 failed) with ruby-install
.
Any ideas?
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 5
- Comments: 17 (1 by maintainers)
Aha! It looks like the
--enable-shared
flag is all that is needed.https://github.com/ruby/ruby/pull/6440 is different changesets from 3.2.0-preview2. We already merged patch same as preview2 to 2.7 to 3.1 branches. https://github.com/ruby/ruby/pull/6440 is the additional fix for Ventura and Xcode14.
We have a plan to merge them to 2.7-3.1 and release a new stable versions.
๐๐ป Thx a ton @monfresh for troubleshooting this issue. Really helpful.
I just ran into this same issue trying to install 3.1.2 with OS 12.6.3 on M1. I had ruby 3.1.3 installed already, but was unable to compile 3.1.2 using
ruby-install
ormake
ruby-install 3.1.2 -- --enable-shared
worked fine. ๐Also hey @monfresh ๐ ๐
Hi @lacostenycoder. That is a known issue with v14+ of Appleโs command line tools. I wrote an article that goes over all the possible solutions: https://www.rubyonmac.dev/how-to-install-ruby-2-6-on-macos-13-ventura