ruby-build: Ruby 2.2.2 build fail error on macOS 11.1
Hello there! (And, Happy New Year!) I hope I am posting this in the right place! 🙏
I am trying to install Ruby 2.2.2 on macOS 11.1 for a project, but am running into the following error when running:
rbenv install 2.2.2
Error:
Downloading openssl-1.0.2u.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16
Installing openssl-1.0.2u...
Installed openssl-1.0.2u to /Users/findum/.rbenv/versions/2.2.2
Downloading ruby-2.2.2.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.bz2
Installing ruby-2.2.2...
WARNING: ruby-2.2.2 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.
ruby-build: using readline from homebrew
BUILD FAILED (macOS 11.1 using ruby-build 20201225)
Inspect or clean up the working tree at /var/folders/x8/g8yqvrh55gq0wds4hny1t94r0000gn/T/ruby-build.20210101111906.42540.uFRvAN
Results logged to /var/folders/x8/g8yqvrh55gq0wds4hny1t94r0000gn/T/ruby-build.20210101111906.42540.log
Last 10 log lines:
compiling ../.././ext/psych/yaml/parser.c
linking shared-object json/ext/parser.bundle
linking shared-object pathname.bundle
installing default psych libraries
linking shared-object json/ext/generator.bundle
linking shared-object bigdecimal.bundle
linking shared-object psych.bundle
linking shared-object nkf.bundle
linking shared-object date_core.bundle
make: *** [build-ext] Error 2
I have tried the workarounds in issue #1353 and have downloaded OpenSSL 1.0 on my system, but still no luck! Has anyone had a similar issue that they were able to resolve? Many thanks 🙏
UPDATE
Solution:
$ CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.2.2
https://github.com/rbenv/ruby-build/issues/1489#issue-741155490
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 10
- Comments: 28 (2 by maintainers)
Thank you @eveevans and @mrmanc the following worked for me:
I know that this is a rbenv post. But I want to comment that I was able to install an old Ruby (2.3.8) on my M1 with Big Sur 11.1, running XCode 12.3 with RVM using the following commands:
On Ruby 2.6 I’m seeing
RUBY_PLATFORMreturn-darwin21instead ofarm64-darwin21– it’s otherwise building successfully witharm64(after I addRUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC):But then:
So the the “badly named file” (
-darwin20-fake.rb) is likely because the architecture is showing up blank somewhere and leads to a platform string like-darwin20. Anyone know how that string gets set and if it can be fixed at build time (or at runtime even)?It isn’t exactly the same issue, but I wanted to share that the solution shared by @eveevans which set
optflagssolved the problem I was having runningrbenv install 2.7.1. SettingCFLAGSdid not work for me.But if i’m understanding your code you’re actually building for x86 using rosetta, no?
The following worked for me:
thanks a lot, worked for me.
Is there a consensus here on whether 2.2.2 can indeed be built on M1 Silicon with ARM? I’m seeing the following error on install:
after trying https://github.com/rbenv/ruby-build/issues/1700#issuecomment-799541819
Are we just not able to build this version of ruby for ARM and have to use Rosetta?