Skip to content

Unable to install any Ruby versions after updating to macOS 12.6 on Apple Silicon #430

Open

Description

@monfresh

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?

ruby-install-failure.txt

Activity

  1. monfresh commented on Sep 15, 2022

    @monfresh
    Author

    The other difference between the iMac and Intel MacBook Air is that the Air had a clean dev setup, but not the iMac. I will try resetting the iMac later and report back.

  2. monfresh commented on Sep 16, 2022

    @monfresh
    Author

    I did some more research and found the exact same error with arith_seq in this Ruby bug report:

    https://bugs.ruby-lang.org/issues/18912

    They ran into it with macOS 13 Ventura Beta, which was using Xcode 14 Beta. And now macOS 12.6 uses Xcode 14 as well, which is why we're seeing this issue now.

    In the Ruby bug report, they say the fix is to add these configuration flags: --with-out-ext=+,bigdecimal --enable-shared. While comparing the output between rbenv and ruby-install, I had noticed that rbenv was setting enabled shared to yes, but ruby-install was not. So that gave me hope.

    I tried to compile Ruby manually again with these new flags, but it still didn't work. Then I realized that maybe the first flag wasn't supposed to be used as written in the bug report, but maybe as two separate flags: --with-out-ext=+ --with-out-ext=bigdecimal. And that worked!

    Here is the whole configuration I used:

    ./configure --with-opt-dir="$(brew --prefix openssl@1.1):$(brew --prefix readline):$(brew --prefix libyaml):$(brew --prefix gdbm)" --with-out-ext=+ --with-out-ext=bigdecimal --enable-shared --prefix=/U
    sers/moncef/.rubies/ruby-3.1.2
    

    So then I tried using those flags with ruby-install:

    ruby-install 3.1.2 -- --with-out-ext=+ --with-out-ext=bigdecimal --enable-shared
    

    And it worked!

    🎉

  3. monfresh commented on Sep 16, 2022

    @monfresh
    Author

    Looks like this is not needed: --with-out-ext=+, so it's just:

    ruby-install 3.1.2 -- --with-out-ext=bigdecimal --enable-shared
    

    Note that this only works for 2.7.x and above. I was not able to install 2.6.9 or 2.6.10 with these flags.

  4. monfresh commented on Sep 16, 2022

    @monfresh
    Author

    While that works in terms of installing Ruby, it breaks Rails apps because they need bigdecimal, so I guess it's back to square one.

  5. monfresh commented on Sep 16, 2022

    @monfresh
    Author

    Aha! It looks like the --enable-shared flag is all that is needed.

  6. monfresh commented on Sep 21, 2022

    @monfresh
    Author

    Here's a more detailed blog post for anyone running into this: https://www.rubyonmac.dev/how-to-install-ruby-on-macos-12-6-apple-silicon/

    Also, I'll note that I was able to install 3.2.0-preview2 without having to add any special flags, so it looks like this issue is resolved upstream. Hopefully, they will port it back to 2.7.7.

  7. havenwood commented on Sep 26, 2022

    @havenwood
    Collaborator

    @monfresh this patch back ports the fix. ruby/ruby#6440 I expect it will be merged soon.

  8. monfresh commented on Sep 26, 2022

    @monfresh
    Author

    @havenwood Thanks for the update! Do you know if it will be backported to 2.7 as well, or just 3.1?

  9. hsbt commented on Sep 26, 2022

    @hsbt
    Contributor

    ruby/ruby#6440 is different changesets from 3.2.0-preview2. We already merged patch same as preview2 to 2.7 to 3.1 branches. ruby/ruby#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.

  10. ebouchut commented on Oct 11, 2022

    @ebouchut

    🙏🏻 Thx a ton @monfresh for troubleshooting this issue.
    Really helpful.

  11. skull-squadron commented on Oct 25, 2022

    @skull-squadron

    @hsbt I hope so. Some of us are forced to support Ruby at work as old as 2.4 because it's in production. On the plus side, it's not like the 1.8.7 forks that lived on forever. :) At home, it's nice to have the luxuries of 3.1 to HEAD mjit and rbs.

  12. monfresh commented on Oct 25, 2022

    @monfresh
    Author

    @steakknife I find that first statement fascinating. Are you saying that because an app is using a particular version of Ruby in production, you're stuck using that version forever? What is preventing you from updating to newer Ruby versions?

  13. lacostenycoder commented on Dec 13, 2022

    @lacostenycoder

    I'm having this issue on MBP M1 running MacOS 13.0.1 and can't install Ruby 2.6.10 with any of the solutions here. Any ideas?

    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-darwin22/strscan.bundle] Error 1
    make[1]: *** [ext/strscan/all] Error 2
    make: *** [build-ext] Error 2
    

    GEM ENV

    gem env
    RubyGems Environment:
      - RUBYGEMS VERSION: 3.3.26
      - RUBY VERSION: 3.1.3 (2022-11-24 patchlevel 185) [arm64-darwin22]
      - INSTALLATION DIRECTORY: /Users/lance/.gem/ruby/3.1.3
      - USER INSTALLATION DIRECTORY: /Users/lance/.gem/ruby/3.1.0
      - RUBY EXECUTABLE: /Users/lance/.rubies/ruby-3.1.3/bin/ruby
      - GIT EXECUTABLE: /usr/bin/git
      - EXECUTABLE DIRECTORY: /Users/lance/.gem/ruby/3.1.3/bin
      - SPEC CACHE DIRECTORY: /Users/lance/.gem/specs
      - SYSTEM CONFIGURATION DIRECTORY: /Users/lance/.rubies/ruby-3.1.3/etc
      - RUBYGEMS PLATFORMS:
         - ruby
         - arm64-darwin-22
      - GEM PATHS:
         - /Users/lance/.gem/ruby/3.1.3
         - /Users/lance/.rubies/ruby-3.1.3/lib/ruby/gems/3.1.0
      - GEM CONFIGURATION:
         - :update_sources => true
         - :verbose => true
         - :backtrace => true
         - :bulk_threshold => 1000
      - REMOTE SOURCES:
         - https://rubygems.org/
      - SHELL PATH:
         - /Users/lance/.gem/ruby/3.1.3/bin
         - /Users/lance/.rubies/ruby-3.1.3/lib/ruby/gems/3.1.0/bin
         - /Users/lance/.rubies/ruby-3.1.3/bin
         - /opt/homebrew/bin
         - /opt/homebrew/sbin
         - /usr/local/bin
         - /System/Cryptexes/App/usr/bin
         - /usr/bin
         - /bin
         - /usr/sbin
         - /sbin
    
  14. monfresh commented on Dec 13, 2022

    @monfresh
    Author

    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

  15. yuletide commented on Jan 31, 2023

    @yuletide

    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 or make

    ruby-install 3.1.2 -- --enable-shared worked fine. 🙏

    Also hey @monfresh :D 👋

  16. monfresh commented on Feb 10, 2023

    @monfresh
    Author

    Hey @yuletide! I'm glad it worked, but I'm curious why you needed to install 3.1.2 instead of updating your project to 3.1.3.

  17. yuletide commented on Feb 10, 2023

    @yuletide

    @monfresh Client work... they were already all setup using 3.1.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions