asdf-ruby
asdf-ruby copied to clipboard
Installing Ruby 2.6 on macOS 12.6 Fails
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:
- Remove Xcode (version 14):
sudo rm -rf /Library/Developer/CommandLineTools
- Go to Xcode's download page: https://developer.apple.com/download/all/?q=Xcode
- Create an account if necessary
- Download Xcode 13.4.1
- Install Xcode
- 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) - 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....
I get exactly the same error, on macOS 12.6 , Pro M1.
Thank you for posting the issue.
solved it with reinstall command line tool 13.4, thanks for your help
For me, it hasn't worked. I installed ruby version 2.7.6
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.)
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?
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.
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?
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
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?
- As I know there're 2 ways to access terminal in rosetta mode (I tried all):
- Next, I installed Homebrew in rosetta terminal ref:
- Default homebrew: /opt/homebrew/bin/brew
- Rosetta homebrew: /usr/local/homebrew/bin/brew
- Then I installed asdf via Rosetta homebrew
- Finally, I did all steps op mentions above. (remove xcode v14, install xcode v13, switch, install ruby with flags)
@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:
- ~~Remove Xcode (version 14): sudo rm -rf /Library/Developer/CommandLineTools~~
- Go to Xcode's download page: https://developer.apple.com/download/all/?q=Xcode
- Create an account if necessary
- Download Xcode 13.4.1 (not the Command Line Utils but the full 10Gb install)
- Manually unpack Xcode and place it somewhere.
- 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)
- 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
@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:
- ~Remove Xcode (version 14): sudo rm -rf /Library/Developer/CommandLineTools~
- Go to Xcode's download page: https://developer.apple.com/download/all/?q=Xcode
- Create an account if necessary
- Download Xcode 13.4.1 (not the Command Line Utils but the full 10Gb install)
- Manually unpack Xcode and place it somewhere.
- 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)
- 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
for rbenv users do this
- Remove Xcode (version 14):
sudo rm -rf /Library/Developer/CommandLineTools
- Go to Xcode's download page: https://developer.apple.com/download/all/?q=Xcode
- Create an account if necessary
- Download Xcode 13.4
- Install Xcode
- 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) - install ruby like this:
optflags=-Wno-error=implicit-function-declaration rbenv install [version]
mine was 2.6.0
@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:
- ~Remove Xcode (version 14): sudo rm -rf /Library/Developer/CommandLineTools~
- Go to Xcode's download page: https://developer.apple.com/download/all/?q=Xcode
- Create an account if necessary
- Download Xcode 13.4.1 (not the Command Line Utils but the full 10Gb install)
- Manually unpack Xcode and place it somewhere.
- 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)
- 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 !!
Running this worked for me in Ventura (13.2):
export optflags="-w"
asdf install ruby 2.6.6
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".
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