asdf-ruby icon indicating copy to clipboard operation
asdf-ruby copied to clipboard

Installing Ruby 2.6 on macOS 12.6 Fails

Open edmangimelli opened this issue 2 years ago • 16 comments

Alternate title: Installing Ruby 2.6, when Xcode 14 is Installed, Fails

(If you're having problems with Ruby 2.7 or Ruby 3, you might try these env variables)


Updated to macOS 12.6 and Ruby 2.6.5, 2.6.6, 2.6.9, and 2.6.10 no longer install.

Someone's gonna find a better solution (thank you in advance!), but this works for now:

  1. Remove Xcode (version 14): sudo rm -rf /Library/Developer/CommandLineTools
  2. Go to Xcode's download page: https://developer.apple.com/download/all/?q=Xcode
  3. Create an account if necessary
  4. Download Xcode 13.4.1
  5. Install Xcode
  6. Tell your terminal where Xcode lives now: (Mine ended up in my Downloads folder) In a terminal tab, sudo xcode-select --switch "$HOME/Downloads/Xcode.app" (but replace that path with the correct one for you)
  7. Install Ruby with these flags

What kinds of errors was I seeing:

BUILD FAILED (macOS 12.6 using ruby-build 20220630)
 
Inspect or clean up the working tree at /var/folders/4y/df7znl5n0nx_39q3rpr9dfmc0000gq/T/ruby-build.20220914224941.69763.pnUSK4
Results logged to /var/folders/4y/df7znl5n0nx_39q3rpr9dfmc0000gq/T/ruby-build.20220914224941.69763.log
 
Last 10 log lines:
transform_mjit_header: SKIPPED to transform __inline_isfinitel
transform_mjit_header: SKIPPED to transform __inline_isfinited
transform_mjit_header: SKIPPED to transform __inline_isfinitef
transform_mjit_header: SKIPPED to transform __darwin_fd_clr
transform_mjit_header: SKIPPED to transform __darwin_fd_set
transform_mjit_header: SKIPPED to transform __darwin_fd_isset
transform_mjit_header: SKIPPED to transform __darwin_check_fd_set
transform_mjit_header: SKIPPED to transform __sputc
transdb.h updated
ln -sf ../../../.ext/include/-darwin21/rb_mjit_min_header-2.6.6.h include/ruby-2.6.0/-darwin21/rb_mjit_min_header-2.6.6.h
linking shared-library libruby.2.6.dylib
Undefined symbols for architecture arm64:
  "__mh_execute_header", referenced from:
      _rb_dump_backtrace_with_lines in addr2line.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libruby.2.6.dylib] Error 1
make: *** Waiting for unfinished jobs....

edmangimelli avatar Sep 15 '22 06:09 edmangimelli

I get exactly the same error, on macOS 12.6 , Pro M1.

Thank you for posting the issue.

MikkelStorgaard avatar Sep 15 '22 16:09 MikkelStorgaard

solved it with reinstall command line tool 13.4, thanks for your help

whchi avatar Oct 07 '22 02:10 whchi

For me, it hasn't worked. I installed ruby version 2.7.6

likhuta avatar Oct 10 '22 10:10 likhuta

A coworker pointed me towards this change, specifically the use of _mh_execute_header here. He noted that this was changed in 2.7, hence 2.7 building successfully with Xcode 14.

I don't know whether this information is likely to help resolve the underlying issue but thought it couldn't hurt to share nevertheless.

In my case the instructions above did work — in particular, simply installing Xcode 13 was not sufficient, the linked build flags in point 7 are also required. (Previously I'd tried the build flags but used Xcode 14, which was of course unsuccessful, so I wanted to test a build on Xcode 13 without those flags to understand their impact.)

benjamineskola avatar Oct 10 '22 11:10 benjamineskola

Thank for this report @edmangimelli. I am trying to go through this on an M1 Pro running Ventura 13.0.1 in order that I can successfully install Ruby 2.6.1 which I need for an old project. Having deleted downloaded the xcode-select 14 that I had on my system and downloaded xcode 13.6 I now have my OS telling me; 'The version of Xcode installed on this Mac is not compatible with macOS Ventura. Download the latest version for free from the App Store.', any ideas how I can over ride this, or whether there's a better fix to this Ruby 2.6 compile issue than this Xcode old version workaround?

jbk2 avatar Nov 11 '22 09:11 jbk2

It's worked on my M1 Air macOS Ventura 13.0.1. I installed ruby version 2.6.3 I made a mistake when install step 7 with the latest ruby-build. Reinstall with v20220630 worked as expected. Thank you so much. You saved my day man. UPDATE: successfully installed ruby 2.3.0 in rosetta terminal.

leminh0796 avatar Nov 17 '22 04:11 leminh0796

It's worked on my M1 Air macOS Ventura 13.0.1. I installed ruby version 2.6.3 I made a mistake when install step 7 with the latest ruby-build. Reinstall with v20220630 worked as expected. Thank you so much. You saved my day man. UPDATE: successfully installed ruby 2.3.0 in rosetta terminal.

@leminh0796 would you mind sharing the steps you followed to install using a rosetta terminal?

lokulin avatar Nov 18 '22 04:11 lokulin

I confirmed this issue on a 3 monterey M1 computers about 3 weeks ago. Solution was to force install of the older 13.x xcode manually, versus installing xcode via the cli per the original bug. This isn't really an asdf issue per se (I saw it with 2 rbenv users, and 1 rvm user) but I am grateful for this post because we eventually stumbled across it via googling for the error message so thank you for sharing.

edit: no rosetta terminal needed. we installed it normally

jaydorsey avatar Nov 19 '22 12:11 jaydorsey

It's worked on my M1 Air macOS Ventura 13.0.1. I installed ruby version 2.6.3 I made a mistake when install step 7 with the latest ruby-build. Reinstall with v20220630 worked as expected. Thank you so much. You saved my day man. UPDATE: successfully installed ruby 2.3.0 in rosetta terminal.

@leminh0796 would you mind sharing the steps you followed to install using a rosetta terminal?

  1. As I know there're 2 ways to access terminal in rosetta mode (I tried all):
    • Clone Terminal, right click Get Info, check the Open in Rosetta option. ref
    • Use Josh Holtz's shared shell settings. this link
  2. Next, I installed Homebrew in rosetta terminal ref:
    • Default homebrew: /opt/homebrew/bin/brew
    • Rosetta homebrew: /usr/local/homebrew/bin/brew
  3. Then I installed asdf via Rosetta homebrew
  4. Finally, I did all steps op mentions above. (remove xcode v14, install xcode v13, switch, install ruby with flags)

leminh0796 avatar Nov 19 '22 12:11 leminh0796

@leminh0796 thanks! @jaydorsey Can confirm I also got it working without rosetta. I initially misread step 4 as installing XCode CLT v13.x which no longer works on Ventura. Manually unpacking Xcode 13 however and using xcode-select to point at that version as in the above instructions does the trick tho.

These are the steps I followed for Ventura:

  1. ~~Remove Xcode (version 14): sudo rm -rf /Library/Developer/CommandLineTools~~
  2. Go to Xcode's download page: https://developer.apple.com/download/all/?q=Xcode
  3. Create an account if necessary
  4. Download Xcode 13.4.1 (not the Command Line Utils but the full 10Gb install)
  5. Manually unpack Xcode and place it somewhere.
  6. Tell your terminal where Xcode lives now: (Mine ended up in my Downloads folder)
  • In a terminal tab, sudo xcode-select --switch "$HOME/Downloads/Xcode.app" (but replace that path with the correct one for you)
  1. Install with the flags from: https://github.com/asdf-vm/asdf-ruby/issues/285
  • optflags=-Wno-error=implicit-function-declaration ASDF_RUBY_BUILD_VERSION=v20220630 asdf install ruby SOME_VERSION

lokulin avatar Nov 21 '22 22:11 lokulin

@leminh0796 thanks! @jaydorsey Can confirm I also got it working without rosetta. I initially misread step 4 as installing XCode CLT v13.x which no longer works on Ventura. Manually unpacking Xcode 13 however and using xcode-select to point at that version as in the above instructions does the trick tho.

These are the steps I followed for Ventura:

  1. ~Remove Xcode (version 14): sudo rm -rf /Library/Developer/CommandLineTools~
  2. Go to Xcode's download page: https://developer.apple.com/download/all/?q=Xcode
  3. Create an account if necessary
  4. Download Xcode 13.4.1 (not the Command Line Utils but the full 10Gb install)
  5. Manually unpack Xcode and place it somewhere.
  6. Tell your terminal where Xcode lives now: (Mine ended up in my Downloads folder)
  • In a terminal tab, sudo xcode-select --switch "$HOME/Downloads/Xcode.app" (but replace that path with the correct one for you)
  1. Install with the flags from: ruby installs failing for Macs (openssl 1.1.1q) #285
  • optflags=-Wno-error=implicit-function-declaration ASDF_RUBY_BUILD_VERSION=v20220630 asdf install ruby SOME_VERSION

Thank you, @lokulin It also worked for me

bruno-nascimento avatar Dec 08 '22 19:12 bruno-nascimento

for rbenv users do this

  1. Remove Xcode (version 14): sudo rm -rf /Library/Developer/CommandLineTools
  2. Go to Xcode's download page: https://developer.apple.com/download/all/?q=Xcode
  3. Create an account if necessary
  4. Download Xcode 13.4
  5. Install Xcode
  6. Tell your terminal where Xcode lives now: (Mine ended up in my Downloads folder)
  7. In a terminal tab, sudo xcode-select --switch "$HOME/Downloads/Xcode.app" (but replace that path with the correct one for you)
  8. install ruby like this: optflags=-Wno-error=implicit-function-declaration rbenv install [version]

mine was 2.6.0

maruarcus avatar Dec 19 '22 20:12 maruarcus

@leminh0796 thanks! @jaydorsey Can confirm I also got it working without rosetta. I initially misread step 4 as installing XCode CLT v13.x which no longer works on Ventura. Manually unpacking Xcode 13 however and using xcode-select to point at that version as in the above instructions does the trick tho.

These are the steps I followed for Ventura:

  1. ~Remove Xcode (version 14): sudo rm -rf /Library/Developer/CommandLineTools~
  2. Go to Xcode's download page: https://developer.apple.com/download/all/?q=Xcode
  3. Create an account if necessary
  4. Download Xcode 13.4.1 (not the Command Line Utils but the full 10Gb install)
  5. Manually unpack Xcode and place it somewhere.
  6. Tell your terminal where Xcode lives now: (Mine ended up in my Downloads folder)
  • In a terminal tab, sudo xcode-select --switch "$HOME/Downloads/Xcode.app" (but replace that path with the correct one for you)
  1. Install with the flags from: ruby installs failing for Macs (openssl 1.1.1q) #285
  • optflags=-Wno-error=implicit-function-declaration ASDF_RUBY_BUILD_VERSION=v20220630 asdf install ruby SOME_VERSION

I just spent 4h trying pretty much everything on the internet, your solution is the only one that worked for me!

Thank you so much @lokulin !!

Kevin-DDR avatar Dec 21 '22 12:12 Kevin-DDR

Running this worked for me in Ventura (13.2):

export optflags="-w"
asdf install ruby 2.6.6

dportalesr avatar Feb 28 '23 03:02 dportalesr

A workaround I found is the following:

brew install [email protected]
ln -s $(brew --prefix [email protected]) ~/.asdf/installs/ruby/2.6.10
asdf reshim ruby 2.6.10

I added more context in this stackoverflow post. I wonder if it would be worth documenting out of band installs on the readme for scenarios like this? It's fairly edge case, but I suspect a number of folks will continue to run into this over the next year or two, and not everyone will have the option to "just upgrade".

tatethurston avatar May 05 '23 16:05 tatethurston

The command from @lokulin's instructions worked for me (on macOS Sonoma 14.3 with xcode CL tools 15.1) without having to download an older Xcode or switch CL tools:

optflags=-Wno-error=implicit-function-declaration ASDF_RUBY_BUILD_VERSION=v20220630 asdf install ruby 2.6.6

sachie avatar Feb 08 '24 20:02 sachie