Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing Ruby 2.6 on macOS 12.6 Fails #301

Open
edmangimelli opened this issue Sep 15, 2022 · 16 comments
Open

Installing Ruby 2.6 on macOS 12.6 Fails #301

edmangimelli opened this issue Sep 15, 2022 · 16 comments

Comments

@edmangimelli
Copy link

edmangimelli commented Sep 15, 2022

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 edmangimelli changed the title Installing Ruby on macOS 12.6 Installing Ruby 2.6 on macOS 12.6 Sep 15, 2022
@edmangimelli edmangimelli changed the title Installing Ruby 2.6 on macOS 12.6 Installing Ruby 2.6 on macOS 12.6 Fails Sep 15, 2022
@MikkelStorgaard
Copy link

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

Thank you for posting the issue.

@whchi
Copy link

whchi commented Oct 7, 2022

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

@likhuta
Copy link

likhuta commented Oct 10, 2022

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

@benjamineskola
Copy link

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.)

@jbk2
Copy link

jbk2 commented Nov 11, 2022

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?

@leminh0796
Copy link

leminh0796 commented Nov 17, 2022

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.

@lokulin
Copy link

lokulin commented Nov 18, 2022

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?

@jaydorsey
Copy link
Contributor

jaydorsey commented Nov 19, 2022

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

@leminh0796
Copy link

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)

@lokulin
Copy link

lokulin commented Nov 21, 2022

@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

@bruno-nascimento
Copy link

@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

@maruarcus
Copy link

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

@Kevin-DDR
Copy link

@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 !!

@dportalesr
Copy link

dportalesr commented Feb 28, 2023

Running this worked for me in Ventura (13.2):

export optflags="-w"
asdf install ruby 2.6.6

@tatethurston
Copy link

tatethurston commented May 5, 2023

A workaround I found is the following:

brew install ruby@2.6
ln -s $(brew --prefix ruby@2.6) ~/.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".

@sachie
Copy link

sachie commented Feb 8, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests