'M1Mac : rbenv install 2.6.6 Build Failed
When I tried to install ruby2.6.6 on my mac using rbenv, I got a "Builed Failed" message.
Initially, I ran it as follows
% rbenv install 2.6.6
Downloading ruby-2.6.6.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.6.tar.bz2
Installing ruby-2.6.6...
ruby-build: using readline from homebrew
BUILD FAILED (macOS 12.0 using ruby-build 20210825)
Inspect or clean up the working tree at /var/folders/zs/rjdwp8ws5_s4gjd40lj1q2gr0000gn/T/ruby-build.20210912210429.75083.Uqwy5z
Results logged to /var/folders/zs/rjdwp8ws5_s4gjd40lj1q2gr0000gn/T/ruby-build.20210912210429.75083.log
Last 10 log lines:
checking build system type... x86_64-apple-darwin13.4.0
checking host system type... x86_64-apple-darwin13.4.0
checking target system type... x86_64-apple-darwin13.4.0
checking for x86_64-apple-darwin13.4.0-clang... (cached) x86_64-apple-darwin13.4.0-clang
checking for x86_64-apple-darwin13.4.0-gcc... (cached) x86_64-apple-darwin13.4.0-clang
checking whether the C compiler works... no
configure: error: in `/var/folders/zs/rjdwp8ws5_s4gjd40lj1q2gr0000gn/T/ruby-build.20210912210429.75083.Uqwy5z/ruby-2.6.6':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** No targets specified and no makefile found. Stop.
As you can see in the output, "checking whether the C compiler works... no", I thought the compiler was not working properly and looked for a solution.
There is a solution to run it by specifying the GCC path, and I used that as a reference to run it as follows.
CC=/usr/bin/gcc rbenv install 2.6.6
However, the result was "Build Failed".
The version of gcc is as follows
%gcc --version
Configured with: --prefix=/Applications/Xcode-beta.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: x86_64-apple-darwin21.1.0
Thread model: posix
InstalledDir: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
The output and log when the path of gcc is specified are as follows.
% CC=/usr/bin/gcc rbenv install 2.6.6
CC=/usr/bin/gcc rbenv install 2.6.6
Downloading ruby-2.6.6.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.6.tar.bz2
Installing ruby-2.6.6...
ruby-build: using readline from homebrew
BUILD FAILED (macOS 12.0 using ruby-build 20210825)
Inspect or clean up the working tree at /var/folders/zs/rjdwp8ws5_s4gjd40lj1q2gr0000gn/T/ruby-build.20210912211846.75422.XoStEO
Results logged to /var/folders/zs/rjdwp8ws5_s4gjd40lj1q2gr0000gn/T/ruby-build.20210912211846.75422.log
Last 10 log lines:
transform_mjit_header: SKIPPED to transform __inline_isinff
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
ln -sf ../../../.ext/include/x86_64-darwin13/rb_mjit_min_header-2.6.6.h include/ruby-2.6.0/x86_64-darwin13/rb_mjit_min_header-2.6.6.h
I thought gcc was not compiling properly, so I tried reinstalling it using homebrew, but it did not work.
I'm having trouble finding a solution to this problem. If anyone can tell me what to do, I'd appreciate your response.
Solution 1:[1]
YARV 2.6 is not supported on Apple Silicon.
As you can see in the issue which is used to track which branches of YARV the fixes for Apple Silicon need to be back ported to, 2.6 is marked as "REQUIRED", meaning it needs a back port in order to work, but this back port has not been done yet. (Compare with 2.7 which is marked as "DONE".)
Backport: 2.5: UNKNOWN, 2.6: REQUIRED, 2.7: DONE
Considering that the back port to 2.7 happened a year ago, we can assume that the maintainers do not intend to apply it to 2.6. Which makes sense: YARV 2.6 is in "security maintenance" status, which means only security fixes are done, and this is not a security issue.
Solution 2:[2]
The solution on this blog post worked for me. The author suggested:
RUBY_CONFIGURE_OPTS=--with-readline-dir="$(abrew --prefix readline)" rbenv install 3.0.0
But as it mentions that you no longer need to load different versions of Homebrew for Intel/M1 Macs, you no longer need to set abrew
and ibrew
. So, what worked for me was:
RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" rbenv install 2.6.6
Note the simple change from abrew
to brew
.
Solution 3:[3]
possible to install using below link on m1 RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.6.6 https://almonta2021blog.com/%E3%80%90ruby%E3%80%91m1-mac%E3%81%A7ruby%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E3%81%AE%E9%9A%9B%E3%81%AB%E3%82%A8%E3%83%A9%E3%83%BC%E3%81%A8%E3%81%AA%E3%82%8B/
Solution 4:[4]
I had success installing 2.6.3 with the following
CFLAGS="-Wno-error=implicit-function-declaration -Wcompound-token-split-by-macro" rbenv install 2.6.3
Source: https://github.com/rbenv/ruby-build/issues/1725#issuecomment-927446555
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jörg W Mittag |
Solution 2 | therealrodk |
Solution 3 | Dinakar Prasad Maurya |
Solution 4 | eudox |