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

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

Open iftheshoefritz opened this issue 3 years ago • 8 comments

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 avatar Apr 14 '21 13:04 iftheshoefritz

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 avatar Apr 19 '21 16:04 iftheshoefritz

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

iftheshoefritz avatar Apr 23 '21 07:04 iftheshoefritz

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.

noraj avatar Jul 21 '21 15:07 noraj

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

iftheshoefritz avatar Jul 22 '21 08:07 iftheshoefritz

@iftheshoefritz don't use an M1 then ?

airtonix avatar Mar 10 '22 02:03 airtonix

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

noraj avatar Mar 10 '22 19:03 noraj

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

iftheshoefritz avatar Mar 11 '22 09:03 iftheshoefritz

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

airtonix avatar Apr 06 '22 23:04 airtonix

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

SeanSith avatar Mar 30 '23 20:03 SeanSith

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.

iftheshoefritz avatar May 09 '23 08:05 iftheshoefritz

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.

Stratus3D avatar May 11 '23 15:05 Stratus3D