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

Big Sur / M1: Multiple versions fail with "machine arm64-apple not recognised" #210

Closed
iftheshoefritz opened this issue Apr 14, 2021 · 11 comments

Comments

@iftheshoefritz
Copy link

I'm on an M1 MBP 13". All the Ruby versions I've tried except v3 have failed to install:

~  asdf install ruby 2.6.5
Downloading openssl-1.1.1j.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/aaf2fcb575cdf6491b98ab4829abf78a3dec8402b8b81efc8f23c00d443981bf
Installing openssl-1.1.1j...
Installed openssl-1.1.1j to /Users/fm/.asdf/installs/ruby/2.6.5

Downloading ruby-2.6.5.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.5.tar.bz2
Installing ruby-2.6.5...
ruby-build: using readline from homebrew

BUILD FAILED (macOS 11.2.3 using ruby-build 20210405)

Inspect or clean up the working tree at /var/folders/_m/8mld51pj7tn48mztkc9j3p3c0000gn/T/ruby-build.20210414142348.38483.WVGX2Y
Results logged to /var/folders/_m/8mld51pj7tn48mztkc9j3p3c0000gn/T/ruby-build.20210414142348.38483.log

Last 10 log lines:
/Users/fm/.asdf/installs/ruby/2.6.5/openssl/share/doc/openssl/html/man7/X448.html -> /Users/fm/.asdf/installs/ruby/2.6.5/openssl/share/doc/openssl/html/man7/X25519.html
/Users/fm/.asdf/installs/ruby/2.6.5/openssl/share/doc/openssl/html/man7/x509.html
/var/folders/_m/8mld51pj7tn48mztkc9j3p3c0000gn/T/ruby-build.20210414142348.38483.WVGX2Y ~
~
/var/folders/_m/8mld51pj7tn48mztkc9j3p3c0000gn/T/ruby-build.20210414142348.38483.WVGX2Y ~
/var/folders/_m/8mld51pj7tn48mztkc9j3p3c0000gn/T/ruby-build.20210414142348.38483.WVGX2Y/ruby-2.6.5 /var/folders/_m/8mld51pj7tn48mztkc9j3p3c0000gn/T/ruby-build.20210414142348.38483.WVGX2Y ~
checking for ruby... /Users/fm/.asdf/shims/ruby
checking build system type... Invalid configuration `arm64-apple-darwin20.3.0': machine `arm64-apple' not recognized
configure: error: /bin/sh tool/config.sub arm64-apple-darwin20.3.0 failed
make: *** No targets specified and no makefile found.  Stop.

Same error with 2.6.3, 2.6.5, 2.7.1, 2.7.2.

But with 3.0.0:

☁  ~  asdf install ruby 3.0.0
Downloading openssl-1.1.1j.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/aaf2fcb575cdf6491b98ab4829abf78a3dec8402b8b81efc8f23c00d443981bf
Installing openssl-1.1.1j...
Installed openssl-1.1.1j to /Users/fm/.asdf/installs/ruby/3.0.0

Downloading ruby-3.0.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz
Installing ruby-3.0.0...
ruby-build: using readline from homebrew
Installed ruby-3.0.0 to /Users/fm/.asdf/installs/ruby/3.0.0

☁  ~  asdf list ruby
  3.0.0
☁  ~  asdf global ruby 3.0.0
☁  ~  ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [arm64-darwin20]

Why is only 3.0.0 succeeding?

@iftheshoefritz
Copy link
Author

iftheshoefritz commented Apr 19, 2021

The answer is that all the versions that failed are old versions of their respective Ruby families and the build includes an old tools/config.sub which does not know about arm64-apple.... As a result the configure step of the build fails because it cannot work out what to do with the M1 architecture.

Later versions, (e.g. 2.7.3, 2.6.7) build with an updated config.sub.

If I build these older versions from source I can copy in a config.sub from the source of a newer version, and ./configure works.

I am interested in whether it is possible to override what config.sub file gets used in configure with a command line option to asdf-ruby?

@iftheshoefritz
Copy link
Author

iftheshoefritz commented Apr 23, 2021

Update: it is possible to override the result of config.sub by using CONFIGURE_OPTS="--build ...".

Specifying the build argument made this error go away. I passed CONFIGURE_OPTS="--build aarch64-apple-darwin20" to ruby-build. In this case, aarch64-apple-darwin20 is the result of the config.sub (the one included with the Ruby 3 source) on my M1 MBP 13".

@noraj
Copy link

noraj commented Jul 21, 2021

Even if you are able to build the desired ruby version with a M1-based CPU chances are building native-gems will fails too and more generally speaking any dependencies with other languages (nodejs, python, etc.) that has C binding, because ARM architecture is not as well supported as x86 in application development environments.

@iftheshoefritz
Copy link
Author

iftheshoefritz commented Jul 22, 2021

@noraj you seem to be implying that it's not worth getting asdf to install Ruby without problems because native dependencies will cause problems anyway.

In fact all the native dependencies that I've encountered in Ruby or React-Native have either fixed their M1 problems or have a one-line fix that appears at the top of the Google search results. Literally type in the error to Google and find the fix to paste into the terminal. A maximum of 5 minutes each.

On the other hand, this issue delayed me switching my primary work to an M1 machine by a month with full days spent on Google and debugging in the terminal. This is the problem, the issues with native dependencies are trivial by comparison.

That said, I've noticed that most of my colleagues on M1 do not have this issue and I'm perplexed about what the difference could be.

@airtonix
Copy link

@iftheshoefritz don't use an M1 then ?

@noraj
Copy link

noraj commented Mar 10, 2022

@iftheshoefritz I had to help someone with a M1 mac but asdf-ruby was only one of the many problems. Another problem due to the ARM architecture is virtualization. And even problems with all macs (arm and x86) is due to the fact that macos is using bash 3.2 while many bash script expect you to have a least bash 4.0. macs are more suited for VIPs than power user. I'd suggest having a Dell, Lenovo or HP for a pro laptop and then whatever Linux distribution or even windows rather than a mac if you are a power user. But that's totally off-topic.

@iftheshoefritz
Copy link
Author

@airtonix what a bizarre comment. I'm not complaining about using M1, I'm ecstatic with it.

@airtonix
Copy link

airtonix commented Apr 6, 2022

@airtonix what a bizarre comment. I'm not complaining about using M1, I'm ecstatic with it.

Not bizare at all tbh.

if you're wasting days and days because: "M1" - then stop using an M1... go back to using a powerful intel machine.

Until I see the react-native team officially announce support for M1, i'll consider the M1 a risk.

@SeanSith
Copy link
Contributor

@iftheshoefritz As ASDF uses ruby-build to perform the installation, if you're still having issues, you may want to look over there. Would you mind closing the issue if you're otherwise done with it?

@iftheshoefritz
Copy link
Author

Closing this. I'm not on top of the problem anymore but since 2.7 has reached eol and newer versions of ruby do install without problems, it seems obsolete.

@Stratus3D
Copy link
Member

For anyone else experiencing similar issues, please see the ruby-build project specifically, and open any issues there if necessary. As @SeanSith pointed out asdf-ruby uses ruby-build for everything, so we can only provide version/architecture combos supported by ruby-build itself.

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

5 participants