Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Ruby 2.2.2 build fail error on macOS 11.1 #1700

Closed
laynejohnson opened this issue Jan 1, 2021 · 28 comments
Closed

Ruby 2.2.2 build fail error on macOS 11.1 #1700

laynejohnson opened this issue Jan 1, 2021 · 28 comments

Comments

@laynejohnson
Copy link

laynejohnson commented Jan 1, 2021

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

#1489 (comment)

@rahulpuroht
Copy link

rahulpuroht commented Jan 8, 2021

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

@laynejohnson
Copy link
Author

@rahulpuroht Yes! It seems to have been an issue with XCode 12 (Apple changed the default CFLAGS). This solution worked for me: #1489 (comment). I hope you have some luck with it!

@eveevans
Copy link

eveevans commented Jan 14, 2021

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

:(

@stevenjohn
Copy link

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

@hsbt
Copy link
Member

hsbt commented Jan 16, 2021

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.

@stevenjohn
Copy link

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.

@hsbt
Copy link
Member

hsbt commented Jan 16, 2021

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

@stevenjohn
Copy link

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.

@eveevans
Copy link

eveevans commented Jan 17, 2021

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)

@stevenjohn
Copy link

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.

@mrmanc
Copy link

mrmanc commented Jan 30, 2021

It isn’t 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.

@ThomasKoppensteiner
Copy link

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

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

@bradical
Copy link

bradical commented Mar 31, 2021

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 #1700 (comment)

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?

@eveevans
Copy link

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

@bradical
Copy link

bradical commented Mar 31, 2021

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

@bradical
Copy link

bradical commented Apr 1, 2021

@ThomasKoppensteiner i saw you mentioned you got this working: #1700 (comment). Were you on M1 Silicon or Intel?

@stevenjohn any luck on your end since: #1700 (comment)? I agree with you: #1700 (comment) that this is going to be a problem for devs (myself included) who are supporting/maintaining legacy apps.

@ThomasKoppensteiner
Copy link

@bradical I'm using a Intel Core i7.

@asl331
Copy link

asl331 commented Jun 3, 2021

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)

thanks a lot, worked for me.

@namratasaun
Copy link

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)

you are doing this in Rosetta terminal or normal? @eveevans

@namratasaun
Copy link

image
I got this as an error.

When I look into the log file, I get

image

@namratasaun
Copy link

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)

@eveevans I am having issues installing it with openssl. Later when It requires openssl it gives me error saying reinstall using openssl

@crgc
Copy link

crgc commented Dec 6, 2021

The following worked for me:

CFLAGS="-Wno-error=implicit-function-declaration" RUBY_CONFIGURE_OPTS='--with-readline-dir=/usr/local/opt/readline/' arch -x86_64 rbenv install 2.2.2

@bradical
Copy link

bradical commented Dec 6, 2021

is the bottom line that it's not possible to build 2.2.2 for arm64?

@crgc
Copy link

crgc commented Dec 6, 2021

Hi @bradical - the above worked for me with 2.2.2 for arm64. For context, I'm on an M1 Macbook running Big Sur 11.5.2.

@bradical
Copy link

bradical commented Dec 6, 2021

But if i'm understanding your code you're actually building for x86 using rosetta, no?

 arch -x86_64

@crgc
Copy link

crgc commented Dec 6, 2021

Yes, you're right. It's the only way I could make it work, at least with the older Rubies.

@smudge
Copy link

smudge commented Dec 10, 2021

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?

On Ruby 2.6 I'm seeing RUBY_PLATFORM return -darwin21 instead of arm64-darwin21 -- it's otherwise building successfully with arm64 (after I add RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC):

$ file $(rbenv which ruby)
[...]/.rbenv/versions/2.6.5/bin/ruby: Mach-O 64-bit executable arm64

But then:

$ ruby -e "puts RUBY_PLATFORM"
-darwin21

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

@bradical
Copy link

bradical commented Dec 23, 2021

Yes, you're right. It's the only way I could make it work, at least with the older Rubies.

@crgc can you confirm the versions of readline and openssl that you have installed and also your macOS version and whether you installed them with x86_64 on homebrew or arm64? I'm trying your command #1700 (comment) but it's not working for me.

@rbenv rbenv locked and limited conversation to collaborators Dec 26, 2021
@hsbt hsbt converted this issue into discussion #1854 Dec 26, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests