Ruby-build: Ruby 2.2.2 build fail error on macOS 11.1

Created on 1 Jan 2021  路  17Comments  路  Source: rbenv/ruby-build

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 馃檹

Solution:

$ CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.2.2

https://github.com/rbenv/ruby-build/issues/1489#issue-741155490

Most helpful comment

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:

rvm pkg install openssl
export optflags="-Wno-error=implicit-function-declaration"
rvm install ruby-2.3.8 --with-openssl-dir=$HOME/.rvm/usr --rubygems ignore
  1. This install old openSSL as independent dependency (not used for the system)
  2. Change a flag that (I think) was changed on XCode 12
  3. Install Ruby using the openSSL dependency from RVM (not from the system)

All 17 comments

@laynejohnson Having same issue with 2.3.3.Have you found any workaround yet.

@rahulpuroht Yes! It seems to have been an issue with XCode 12 (Apple changed the default CFLAGS). This solution worked for me: https://github.com/rbenv/ruby-build/issues/1489#issue-741155490. I hope you have some luck with it!

Having the same problem on Mac M1
And the fix didn't works for me...
also trying using arch -x86_64 /bin/bash -c 'rbenv install 2.3.8'
and RUBY_CFLAGS="-w" arch -x86_64 /bin/bash -c 'rbenv install 2.3.8'

$ RUBY_CFLAGS="-w" arch -x86_64 /bin/bash -c 'rbenv install 2.3.8'
Downloading openssl-1.0.2u.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16
Installing openssl-1.0.2u...
Installed openssl-1.0.2u to /Users/eveevans/.rbenv/versions/2.3.8

Downloading ruby-2.3.8.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.8.tar.bz2
Installing ruby-2.3.8...

WARNING: ruby-2.3.8 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/l6/vw4xykxj2w1gpnnd0fwqnjqw0000gn/T/ruby-build.20210113205514.35211.BVw2ee
Results logged to /var/folders/l6/vw4xykxj2w1gpnnd0fwqnjqw0000gn/T/ruby-build.20210113205514.35211.log

Last 10 log lines:
installing default psych libraries
compiling ossl_x509crl.c
compiling ossl_x509ext.c
compiling ossl_x509name.c
compiling ossl_x509revoked.c
compiling ossl_x509req.c
compiling ossl_x509store.c
installing default openssl libraries
linking shared-object openssl.bundle
make: *** [build-ext] Error 2

:(

Hi there,

Yes - also trying to get Ruby installed on Mac Silicone m1.

What I've found so far...

`Steves-MacBook-Air:~ steve$ arch -x86_64 /bin/bash -c 'CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.2.5'
Installing openssl-1.0.2u...
Installed openssl-1.0.2u to /Users/steve/.rbenv/versions/2.2.5

Installing ruby-2.2.5...

WARNING: ruby-2.2.5 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/4v/zps5vz_n3xjdmvq8pl_lf9780000gn/T/ruby-build.20210116112712.11791.4koc3o
Results logged to /var/folders/4v/zps5vz_n3xjdmvq8pl_lf9780000gn/T/ruby-build.20210116112712.11791.log

Last 10 log lines:

define HAVE_BN_GENCB defined(HAVE_RSA_GENERATE_KEY_EX) || defined(HAVE_DH_GENERATE_PARAMETERS_EX) || defined(HAVE_DSA_GENERATE_PARAMETERS_EX)

                                                       ^

./ossl_pkey.h:44:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
./ossl_pkey.h:43:103: note: expanded from macro 'HAVE_BN_GENCB'

define HAVE_BN_GENCB defined(HAVE_RSA_GENERATE_KEY_EX) || defined(HAVE_DH_GENERATE_PARAMETERS_EX) || defined(HAVE_DSA_GENERATE_PARAMETERS_EX)

                                                                                                  ^

3 warnings generated.
3 warnings generated.
linking shared-object openssl.bundle
make: * [build-ext] Error 2
`

Using:
arch -x86_64 /bin/bash -c
.... has allowed me to get openssl 1.0.2 to install correctly (without this it fails installing ssl)

and I added:
CFLAGS="-Wno-error=implicit-function-declaration"
.... thanks to this post https://github.com/rbenv/ruby-build/issues/1489

But as you see its not working.

My next attempt followed this: https://stackoverflow.com/questions/64029645/rbenv-ruby-build-installs-fail-for-ruby-versions-1-9-3-2-2-0-2-2-5-with-xcod

which suggests installing command line tools v11, and the setting that in Xcode preferences.

However, on downloading the latest CLTs for v11 (11.5) - the installation says it is not compatible with m1 silicon.

Has anyone got older Ruby with rbenv working on m1 yet? Or found any other steps forward?

Many thanks, Steve.

Has anyone got older Ruby with rbenv working on m1 yet?

There is no way to build the old ruby at M1 macOS with arm arch.

Has anyone got older Ruby with rbenv working on m1 yet?

There is no way to build the old ruby at M1 macOS with arm arch.

I'm sure there'll be a way - else there'll be a very upset group of devs not able to work on older ruby versions.

@stevenjohn Maybe, the old Rubies can work under the Rosseta2 environment. But I have only Apple DTK, I couldn't investigate macOS with M1 chip.

Cheers @hsbt - I've tried using

arch -x86_64 /bin/bash -c

as a prefix which I believe uses Rosseta2

By using this I can see my installation went lot further than before - but I think the issue now is with the v12 command line tools, I'm seeing a lot of references to needing to use v11 - but not sure these can be installed on m1.

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:

rvm pkg install openssl
export optflags="-Wno-error=implicit-function-declaration"
rvm install ruby-2.3.8 --with-openssl-dir=$HOME/.rvm/usr --rubygems ignore
  1. This install old openSSL as independent dependency (not used for the system)
  2. Change a flag that (I think) was changed on XCode 12
  3. Install Ruby using the openSSL dependency from RVM (not from the system)

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:

That's greatly appreciated - I will try it out and report back.

It isn鈥檛 exactly the same issue, but I wanted to share that the solution shared by @eveevans which set optflags solved the problem I was having running rbenv install 2.7.1. Setting CFLAGS did not work for me.

Thank you @eveevans and @mrmanc the following worked for me:

export optflags="-Wno-error=implicit-function-declaration"
rbenv install 2.1.2

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:

config.status: creating -darwin20-fake.rb
rm: illegal option -- a
usage: rm [-f | -i] [-dPRrvW] file ...
       unlink file
config.status: error: could not create -darwin20-fake.rb
make: *** [-darwin20-fake.rb] Error 64

after trying https://github.com/rbenv/ruby-build/issues/1700#issuecomment-799541819

brew install readline rbenv
arch -arm64 brew install rbenv/tap/[email protected]

# add the following to ~/.zshrc
eval "$(rbenv init -)"
# rbenv install recommends this with ruby-build
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix [email protected])"

optflags="-Wno-error=implicit-function-declaration" rbenv install 2.2.2

Are we just not able to build this version of ruby for ARM and have to use Rosetta?

@bradical in my case, I ended using Old rubies compiled with Rosseta 2, and the newest Rubies compiled for ARM.
(with Asdf)

Thanks @eveevans!

This is interesting. It seems to have gotten pretty far and perhaps is just failing in some final symlinking step due to a badly named file -darwin20-fake.rb?

... previous make output...

make[2]: Nothing to be done for `all'.
make[2]: Nothing to be done for `all'.
make[2]: Nothing to be done for `all'.
make[2]: Nothing to be done for `all'.
make[2]: `ruby' is up to date.
Generating RDoc documentation

No newer files.

  Files:      0

  Classes:    0 (0 undocumented)
  Modules:    0 (0 undocumented)
  Constants:  0 (0 undocumented)
  Attributes: 0 (0 undocumented)
  Methods:    0 (0 undocumented)

  Total:      0 (0 undocumented)
    0.00% documented

  Elapsed: 0.0s

config.status: creating -darwin20-fake.rb
rm: illegal option -- a
usage: rm [-f | -i] [-dPRrvW] file ...
       unlink file
config.status: error: could not create -darwin20-fake.rb
make: *** [-darwin20-fake.rb] Error 64

Full log attached
ruby-build.20210331160550.78773.log

@ThomasKoppensteiner i saw you mentioned you got this working: https://github.com/rbenv/ruby-build/issues/1700#issuecomment-799541819. Were you on M1 Silicon or Intel?

@stevenjohn any luck on your end since: https://github.com/rbenv/ruby-build/issues/1700#issuecomment-761956133? I agree with you: https://github.com/rbenv/ruby-build/issues/1700#issuecomment-761548457 that this is going to be a problem for devs (myself included) who are supporting/maintaining legacy apps.

@bradical I'm using a Intel Core i7.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tom-mayer picture tom-mayer  路  3Comments

Lukom picture Lukom  路  5Comments

edap picture edap  路  3Comments

artoodeeto picture artoodeeto  路  4Comments

dpaluy picture dpaluy  路  6Comments