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

Cannot install Ruby versions < 2.4 because of openssl@1.1 dependency #1353

Closed
brandonfriess-stripe opened this issue Oct 3, 2019 · 50 comments
Closed

Comments

@brandonfriess-stripe
Copy link

@brandonfriess-stripe brandonfriess-stripe commented Oct 3, 2019

It seems the most recent change to ruby-build 20191002 homebrew formula to require openssl@1.1 breaks the install of Ruby versions that are < 2.4 (those require openssl 1.0.2q)

So, for macOS users who install ruby-build via homebrew, they will get openssl@1.1 installed as well.

If they then try to run rbenv install 2.1.10 for instance, it will fail with:

Last 10 log lines:
The Ruby openssl extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Configure options used:
  --prefix=/Users/username/.rbenv/versions/2.1.10
  --with-openssl-dir=/usr/local/opt/openssl@1.1
  --with-readline-dir=/usr/local/opt/readline
  CC=clang
  CFLAGS= -O3 -Wno-error=shorten-64-to-32 
  LDFLAGS=-L/Users/username/.rbenv/versions/2.1.10/lib 
  CPPFLAGS=-I/Users/username/.rbenv/versions/2.1.10/include 

Yeah, I know older versions are EOL but they still get used in some environments.

Seems like changing https://github.com/rbenv/ruby-build/blob/master/bin/ruby-build#L1023 to only check for openssl and not `openssl@1.1 could potentially fix this?

@hsbt
Copy link
Member

@hsbt hsbt commented Oct 3, 2019

I understand this issue too. But I didn't know the maintenance policy of ruby-build formula on homebrew.

I suggest you use git clone instead of brew install ruby-build

@gfguthrie
Copy link
Contributor

@gfguthrie gfguthrie commented Oct 3, 2019

Since I helped move the 1.1 change along:

The workaround for EOL Ruby versions (or any that won't build with 1.1) where you still want to use Homebrew is as follows:
brew install openssl
RUBY_CONFIGURE_OPTS="--with-openssl-dir=/usr/local/opt/openssl" rbenv install 2.3.8
Latest solution/workaround (March 2020): #1353 (comment)

(FWIW, the Homebrew formula was updated to use 1.1 at the end of August, the recent change was just to start looking for that version)

@brandonfriess-stripe
Copy link
Author

@brandonfriess-stripe brandonfriess-stripe commented Oct 3, 2019

Thanks! That will work and I am sure will be helpful for others who may land on this thread.

@aardvarkk
Copy link

@aardvarkk aardvarkk commented Oct 4, 2019

I ran into this bug when trying to install Ruby 2.3.8 using the ASDF version manager. I was getting the following error when running:

asdf install ruby 2.3.8:

ERROR: Ruby install aborted due to missing extensions

Following the example above, I changed the command to the following and the installation worked correctly:

RUBY_CONFIGURE_OPTS="--with-openssl-dir=/usr/local/opt/openssl" asdf install ruby 2.3.8

kengorab pushed a commit to policygenius/laptop that referenced this issue Nov 5, 2019
  - `caskroom/cask` no longer needs to be tapped in newer versions of
homebrew: https://stackoverflow.com/a/58337898
  - Resolving openssl version conflict when installing ruby versions
with rbenv: rbenv/ruby-build#1353 (comment)
@wekb
Copy link

@wekb wekb commented Nov 8, 2019

Since I helped move the 1.1 change along:

The workaround for EOL Ruby versions (or any that won't build with 1.1) where you still want to use Homebrew is as follows:

brew install openssl
RUBY_CONFIGURE_OPTS="--with-openssl-dir=/usr/local/opt/openssl" rbenv install 2.3.8

(FWIW, the Homebrew formula was updated to use 1.1 at the end of August, the recent change was just to start looking for that version)

This is very helpful, but frankly this should not have been a breaking change. Adding logic, or at least some kind of user feedback, would have been trivial in this case.

@hraban
Copy link

@hraban hraban commented Nov 8, 2019

Thanks for the explanation and solution.

Even just a link to this issue would be a great help to anyone using rbenv to install a <2.4.0 on mac. Many people will be running into this problem, not all of them confident enough to google the right error message (rbenv is usually part of a "run this to setup the repo" list in project READMEs).

@gfguthrie
Copy link
Contributor

@gfguthrie gfguthrie commented Nov 8, 2019

I've taken option 2 from my comment on the original PR and made a new PR (#1375) to stop looking for Homebrew openssl entirely so that the discussion can focus there about whether that's the approach ruby-build wants to move towards or not.

@hardvain
Copy link

@hardvain hardvain commented Jan 6, 2020

Hello, I still seem to have this error. I am trying to instal ruby 2.3.7. My mac has openssl version 1.1.d 10 Sep 2019. I am getting the following error when trying to install ruby even after passing the above suggested method of including open-ssl-dir. The last few lines of the error is:

openssl_missing.c:39:18: error: expected ';' after top level declarator
EVP_MD_CTX_create(void)
                 ^
                 ;
2 warnings and 5 errors generated.
make[2]: *** [openssl_missing.o] Error 1
make[1]: *** [ext/openssl/all] Error 2
make[1]: *** Waiting for unfinished jobs....
installing default pathname libraries
compiling objspace.c
compiling objspace_dump.c
linking shared-object json/ext/parser.bundle
linking shared-object json/ext/generator.bundle
linking shared-object pathname.bundle
linking shared-object objspace.bundle
linking shared-object bigdecimal.bundle
linking shared-object nkf.bundle
linking shared-object date_core.bundle
make: *** [build-ext] Error 2

Am I missing anything? The command I am trying to run is RUBY_CONFIGURE_OPTS="--with-openssl-dir=/usr/local/opt/openssl" rbenv install 2.3.7

@gfguthrie
Copy link
Contributor

@gfguthrie gfguthrie commented Jan 6, 2020

@hardvain you probably don't need to pass the option at all. 2.3.7 I don't think will work with 1.1, and from the error it looks like you don't have anything in /usr/local/opt/openssl. If you don't pass in anything, ruby-build (assuming you have the current version) will just install the openssl that is needed for 2.3.7.

@jyr
Copy link

@jyr jyr commented Jan 12, 2020

Hi,

I have the same error and tried with multiple options:

$ RUBY_CONFIGURE_OPTS="--with-openssl-dir=/usr/local/opt/openssl" rvm install ruby-2.1.2
$ rvm install --disable-binary  ruby-2.1.2 --autolibs=homebrew --with-openssl-dir=`brew --prefix openssl`
$ rvm install ruby-2.1.2 --autolibs=homebrew --with-openssl-dir=`brew --prefix openssl`

I have OpenSSL 1.1.1d 10 Sep 2019 and I'm using macOS High Sierra version 10.13.6

the error is:

++ printf %b 'command(6): command gem install /Users/jyr/.rvm/gem-cache/gem-wrappers-1.4.0.gem --local --no-document\n'
++ rvm_log 'installing gem /Users/jyr/.rvm/gem-cache/gem-wrappers-1.4.0.gem --local --no-document'
++ [[ '' == 1 ]]
++ printf %b 'installing gem /Users/jyr/.rvm/gem-cache/gem-wrappers-1.4.0.gem --local --no-document\n'
++ command gem install /Users/jyr/.rvm/gem-cache/gem-wrappers-1.4.0.gem --local --no-document
++ gem install /Users/jyr/.rvm/gem-cache/gem-wrappers-1.4.0.gem --local --no-document
ERROR:  Loading command: install (LoadError)
        cannot load such file -- openssl
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass
++ return 1
++ return 1
++ return 1
++ return 1

When I want to install openssl

$ rvm list
=> ruby-2.1.2 [ x86_64 ]
 * ruby-2.6.3 [ x86_64 ]

# => - current
# =* - current && default
#  * - default
$ gem install openssl
ERROR:  Loading command: install (LoadError)
	cannot load such file -- openssl
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass

And I have openssl via homebrew:

$ brew --prefix openssl
/usr/local/opt/openssl@1.1

Thanks a lot

@mislav
Copy link
Member

@mislav mislav commented Jan 12, 2020

@jyr There are multiple things wrong with what you are doing. First of all, you are using rvm, which is an entirely different tool for installing Ruby than this repo is (we are called "ruby-build", also known as "rbenv install").

Second, you clearly have OpenSSL 1.1 installed, and this whole thread is about Ruby 2.3 and lower not being compatible with OpenSSL 1.1. So your method of installation won't work until you install OpenSSL 1.0 on your system.


To others: Homebrew-core has removed their openssl@1.0 formula due to OpenSSL 1.0 reaching end of life last month. This makes it harder to install Ruby 2.3 and older on macOS. You can try the following and see if it works:

brew install rbenv/tap/openssl@1.0
RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.0)" rbenv install 2.3.8

@sco11morgan
Copy link

@sco11morgan sco11morgan commented Jan 13, 2020

Thanks @mislav . One small tweak and it worked for me

brew --prefix openssl@1.0
export LDFLAGS="-L/usr/local/opt/openssl@1.0/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.0/include"
CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.0)" RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.0)" rbenv install 2.3.8

@12masta
Copy link

@12masta 12masta commented Jan 14, 2020

@sco11morgan I am executed your command but I am receiving: Error: No available formula with the name "openssl@1.0" . How you resolved it?

@gfguthrie
Copy link
Contributor

@gfguthrie gfguthrie commented Jan 14, 2020

@12masta you have to install it first from the rbenv tap: brew install rbenv/tap/openssl@1.0

@chetstone
Copy link

@chetstone chetstone commented Jan 21, 2020

I had a similar problem. After unfortunately doing "brew upgrade" I ended up with openssl 1.1.1 installed and a bunch of broken already-installed rubies. To fix those up, I installed openssl@1.0 from the tap as explained by @gfguthrie and @mislav , then, to fix them all, executed the following commands in ~/.rbenv/versions:

$ find . -name \*.bundle -exec /bin/sh -c "file {} | grep -q Mach-O " \; -exec /bin/sh -c "objdump -macho -dylibs-used {} |grep -q libcrypto.1.0 " \; -exec sudo install_name_tool -change /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/opt/openssl@1.0/lib/libcrypto.dylib {} \;
AND
$ find . -name \*.bundle -exec /bin/sh -c "file {} | grep -q Mach-O " \; -exec /bin/sh -c "objdump -macho -dylibs-used {} |grep -q libssl.1.0 " \; -exec  sudo install_name_tool -change /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/opt/openssl@1.0/lib/libssl.dylib {} \;

Before executing this, you might want to print a list of the files you're going to be working on:

find . -name \*.bundle -exec /bin/sh -c "file {} | grep -q Mach-O " \; -exec /bin/sh -c "objdump -macho -dylibs-used {} |grep -q libssl.1.0 " \; -print
AND
find . -name \*.bundle -exec /bin/sh -c "file {} | grep -q Mach-O " \; -exec /bin/sh -c "objdump -macho -dylibs-used {} |grep -q libcrypto.1.0 " \; -print

@ryanwi
Copy link

@ryanwi ryanwi commented Feb 21, 2020

If you don't pass in anything, ruby-build (assuming you have the current version) will just install the openssl that is needed for 2.3.7.

Is this still true? I am trying the solution with brew install rbenv/tap/openssl@1.0 because 2.3.8 is not installing with a fresh rbenv install from homebrew in my case.

$ rbenv install 2.3.8
Downloading openssl-1.0.2u.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16
Installing openssl-1.0.2u...

BUILD FAILED (OS X 10.15.3 using ruby-build 20200218)

Inspect or clean up the working tree at /var/folders/0_/xn1lcks13mz03fwyrh7pzpwm0000gn/T/ruby-build.20200220221514.66307.OxAhCf
Results logged to /var/folders/0_/xn1lcks13mz03fwyrh7pzpwm0000gn/T/ruby-build.20200220221514.66307.log

Last 10 log lines:
      _cca_rsa_sign in e_4758cca.o
      _cca_rsa_verify in e_4758cca.o
  "_i2d_X509_SIG", referenced from:
      _cca_rsa_sign in e_4758cca.o
      _cca_rsa_verify in e_4758cca.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [link_o.darwin] Error 1
make[1]: *** [lib] Error 2
make: *** [build_engines] Error 1

@mislav
Copy link
Member

@mislav mislav commented Feb 21, 2020

@ryanwi Have you passed RUBY_CONFIGURE_OPTS?

RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.0)" rbenv install 2.3.8

@ryanwi
Copy link

@ryanwi ryanwi commented Feb 21, 2020

@mislav Yes, that does work, thank you for providing that. I am able to install 2.3.8 with that fix.

I'm curious though why a plain rbenv install 2.3.8 that attempts to install its own version of openssl is failing. I should note that this is failing for me on all Ruby versions. For more recent versions, I have to set the options to point to Homebrew's 1.1. I have not been successful with installing any Ruby version when rbenv attempts to install the openssl it needs. Does that make sense? Probably something on my machine and/or a separate issue.

These work

brew install rbenv/tap/openssl@1.0
RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.0)" rbenv install 2.3.8

brew install openssl
RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)" rbenv install 2.6.5

These don't

rbenv install 2.3.8
rbenv install 2.6.5

@gfguthrie
Copy link
Contributor

@gfguthrie gfguthrie commented Feb 21, 2020

@ryanwi maybe an issue with 10.15.3 or more likely whatever version of the command line tools you have? I have 10.15.1 & CLTools 11.2.0.0.1.1571444319 and the install for 2.3.8 completed normally.

@mislav
Copy link
Member

@mislav mislav commented Feb 21, 2020

I'm curious though why a plain rbenv install 2.3.8 that attempts to install its own version of openssl is failing.

That's a good question, and I do not have any idea why that is currently happening for you, sorry. 😕

@ryanwi
Copy link

@ryanwi ryanwi commented Feb 21, 2020

I have 10.15.3 with CLITools 11.3.1

$ /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -version
Xcode 11.3.1
Build version 11C504
$ clang -v
Apple clang version 11.0.0 (clang-1100.0.33.17)

@ravicious
Copy link

@ravicious ravicious commented Feb 25, 2020

For the record, I have the same issues as ryanwi with 2.3.3.

Output and Xcode & clang version
~: ruby-build 2.3.3 ~/.rubies/ruby-2.3.3                                                                                [9:34:42]
Downloading openssl-1.0.2u.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16
Installing openssl-1.0.2u...

BUILD FAILED (OS X 10.15.3 using ruby-build 20200115)

Inspect or clean up the working tree at /var/folders/cg/st97khm157s3qn5d7m6d14y80000gn/T/ruby-build.20200225093443.44398.79nKFG
Results logged to /var/folders/cg/st97khm157s3qn5d7m6d14y80000gn/T/ruby-build.20200225093443.44398.log

Last 10 log lines:
      _cca_rsa_sign in e_4758cca.o
      _cca_rsa_verify in e_4758cca.o
  "_i2d_X509_SIG", referenced from:
      _cca_rsa_sign in e_4758cca.o
      _cca_rsa_verify in e_4758cca.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [link_o.darwin] Error 1
make[1]: *** [lib] Error 2
make: *** [build_engines] Error 1
~: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -version                                               [9:39:09]
Xcode 11.2
Build version 11B52
~: clang -v                                                                                                             [9:39:20]
Apple clang version 11.0.0 (clang-1100.0.33.12)
Target: x86_64-apple-darwin19.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

@thefonso
Copy link

@thefonso thefonso commented Mar 18, 2020

Since I helped move the 1.1 change along:

The workaround for EOL Ruby versions (or any that won't build with 1.1) where you still want to use Homebrew is as follows:

brew install openssl
RUBY_CONFIGURE_OPTS="--with-openssl-dir=/usr/local/opt/openssl" rbenv install 2.3.8

(FWIW, the Homebrew formula was updated to use 1.1 at the end of August, the recent change was just to start looking for that version)

AND does this work for ruby 1.9.3-p194 ???
Or ANY ruby under 2.0???

@mullermp
Copy link

@mullermp mullermp commented Aug 19, 2020

@hsbt Thanks for confirming that it's possible to install. I tried uninstalling rbenv/tap/openssl@1.0 to simulate the exact install you did but unfortunately it still doesn't work for me. I'm not sure what I could be doing differently here. Do you have any advice or recommendations on what I could try?

$ rbenv install 1.9.3-p551
Downloading openssl-1.0.2u.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16
Installing openssl-1.0.2u...
Installed openssl-1.0.2u to /Users/mamuller/.rbenv/versions/1.9.3-p551

ruby-build: using libyaml from homebrew
Downloading ruby-1.9.3-p551.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p551.tar.bz2
Installing ruby-1.9.3-p551...

WARNING: ruby-1.9.3-p551 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 (Mac OS X 10.15.6 using ruby-build 20200727)

Inspect or clean up the working tree at /var/folders/65/8ndfq5g12c3bw1ktst21pfs4rn2nnt/T/ruby-build.20200818180658.99119.LK2wsN
Results logged to /var/folders/65/8ndfq5g12c3bw1ktst21pfs4rn2nnt/T/ruby-build.20200818180658.99119.log

Last 10 log lines:
make[2]: *** [ossl_pkcs7.o] Error 1
make[1]: *** [ext/openssl/all] Error 2
make[1]: *** Waiting for unfinished jobs....
installing default nkf libraries
linking shared-object nkf.bundle
ld: warning: directory not found for option '-L/Users/mamuller/.rbenv/versions/1.9.3-p551/lib'
17 warnings generated.
linking shared-object date_core.bundle
ld: warning: directory not found for option '-L/Users/mamuller/.rbenv/versions/1.9.3-p551/lib'
make: *** [build-ext] Error 2

@hsbt
Copy link
Member

@hsbt hsbt commented Aug 19, 2020

Do you have any advice or recommendations on what I could try?

I'm not sure why your installation was failed. At least, It's not an issue of rbenv and ruby-build.

@aruprakshit
Copy link

@aruprakshit aruprakshit commented Sep 6, 2020

I am trying to install 2.3.3 and 2.3.4 as both needed in my project, but installation kept failing.

RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.0)" rbenv install 2.3.4
Error: No available formula with the name "openssl@1.0"
Downloading ruby-2.3.4.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.4.tar.bz2
Installing ruby-2.3.4...

WARNING: ruby-2.3.4 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 (Mac OS X 10.15.6 using ruby-build 20200819)

Inspect or clean up the working tree at /var/folders/r8/4mc1_kfx3qq704csrjdy9c8m0000gn/T/ruby-build.20200906223304.65445.Uas6nA
Results logged to /var/folders/r8/4mc1_kfx3qq704csrjdy9c8m0000gn/T/ruby-build.20200906223304.65445.log

Last 10 log lines:
installing capi-docs:         /Users/aruprakshit/.rbenv/versions/2.3.4/share/doc/ruby
The Ruby openssl extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Configure options used:
  --prefix=/Users/aruprakshit/.rbenv/versions/2.3.4
  --with-openssl-dir=
  --with-readline-dir=/usr/local/opt/readline
  CC=clang
  LDFLAGS=-L/Users/aruprakshit/.rbenv/versions/2.3.4/lib
  CPPFLAGS=-I/Users/aruprakshit/.rbenv/versions/2.3.4/include

Normal installation also fails:

% rbenv install 2.3.4
Downloading ruby-2.3.4.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.4.tar.bz2
Installing ruby-2.3.4...

WARNING: ruby-2.3.4 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 (Mac OS X 10.15.6 using ruby-build 20200819)

Inspect or clean up the working tree at /var/folders/r8/4mc1_kfx3qq704csrjdy9c8m0000gn/T/ruby-build.20200906223908.81806.4Eb3YJ
Results logged to /var/folders/r8/4mc1_kfx3qq704csrjdy9c8m0000gn/T/ruby-build.20200906223908.81806.log

Last 10 log lines:
installing capi-docs:         /Users/aruprakshit/.rbenv/versions/2.3.4/share/doc/ruby
The Ruby openssl extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Configure options used:
  --prefix=/Users/aruprakshit/.rbenv/versions/2.3.4
  --with-openssl-dir=/usr/local/opt/openssl@1.1
  --with-readline-dir=/usr/local/opt/readline
  CC=clang
  LDFLAGS=-L/Users/aruprakshit/.rbenv/versions/2.3.4/lib
  CPPFLAGS=-I/Users/aruprakshit/.rbenv/versions/2.3.4/include
aruprakshit@arups-iMac ~ %

@prpetten
Copy link

@prpetten prpetten commented Sep 7, 2020

@mullermp Did you ever resolve your issue? I'm encountering a similar issue trying to install 2.5.8. where the last bit of output is linking shared-object date_core.bundle

$ rbenv install 2.5.8
Downloading openssl-1.1.1g.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ddb04774f1e32f0c49751e21b67216ac87852ceb056b75209af2443400636d46
Installing openssl-1.1.1g...
Installed openssl-1.1.1g to /Users/paulpettengill/.rbenv/versions/2.5.8

Downloading ruby-2.5.8.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.8.tar.bz2
Installing ruby-2.5.8...

WARNING: ruby-2.5.8 is nearing its end of life.
It only receives critical security updates, no bug fixes.

ruby-build: using readline from homebrew

BUILD FAILED (Mac OS X 10.15.6 using ruby-build 20200819)

Inspect or clean up the working tree at /var/folders/f6/4bg8bgyd3z33ccrd3lc1gd140000gn/T/ruby-build.20200907135317.52026.of1dJh
Results logged to /var/folders/f6/4bg8bgyd3z33ccrd3lc1gd140000gn/T/ruby-build.20200907135317.52026.log

Last 10 log lines:
            ^
              _Nonnull 
193 warnings generated.
linking shared-object -test-/printf.bundle
193 warnings generated.
193 warnings generated.
linking shared-object -test-/proc.bundle
193 warnings generated.
linking shared-object date_core.bundle
make: *** [build-ext] Error 2

@mullermp
Copy link

@mullermp mullermp commented Sep 8, 2020

@prpetten I did resolve the issue but I was unsure how. I ended up nuking a lot of my installations and configurations and redoing it.

@prpetten
Copy link

@prpetten prpetten commented Sep 8, 2020

@mullermp Thanks. For anyone else who comes across this, I ended up nuking Homebrew, X-Code with Dev Tools and re-installing everything, and it worked without issue.

@burnettk
Copy link

@burnettk burnettk commented Sep 21, 2020

@mullermp i am getting the exact same errors as in your gist. i have very simple repro instructions in my gist. it's essentially:

  1. wipe your mac and install Mac OS X 10.15.6 / Catalina
  2. install homebrew
  3. brew install rbenv
  4. rbenv install 2.2.5.

i show that it fails (for me) with the same errors for rubies up to version 2.2.5, and works for ruby versions greater than or equal to 2.3.1. ultimately it gets 3 warnings and 4 errors, and the errors are these:

./openssl_missing.h:71:6: error: conflicting types for 'HMAC_CTX_copy'
./openssl_missing.h:95:5: error: conflicting types for 'EVP_CIPHER_CTX_copy'
./openssl_missing.h:173:5: error: conflicting types for 'BN_rand_range'
./openssl_missing.h:177:5: error: conflicting types for 'BN_pseudo_rand_range'

so unfortunately, nuking everything as @prpetten suggests is not doing it for me.

note that my repro instructions do not mention installing openssl 1.0 from brew, but i also tried that approach as suggested above at #1353 (comment), and it also does not help.

i'm using a 16" 2019 MacBook Pro, which I hope is irrelevant. If anyone has a mac/drive they don't mind wiping, i'd be very interested to know how common this issue is (and of course, what the solution might be). thanks for ruby-build; we'd all be hosed without it.

@bfreezy
Copy link

@bfreezy bfreezy commented Sep 22, 2020

@burnettk what version of Command Line Tools do you have installed? You can check by running clang --version.

I suspect you may have version 12, which was just released by Apple on 9/16/2020. I can replicate a similar error installing 2.2.5 but I don't have this error if I downgrade Command Line Tools to version 11.

@burnettk
Copy link

@burnettk burnettk commented Sep 22, 2020

@bfreezy confirmed, thanks a ton. i was indeed using version 12 of the command line tools, and downgrading to version 11 fixes rbenv install 2.2.5. i wonder what specifically about clang 12 causes this openssl/ruby breakage, and i wonder if people who have to deal with older rubies will be stuck depending on version 11 of the command line tools forever.

@Nucleotide
Copy link

@Nucleotide Nucleotide commented Sep 23, 2020

I can also confirm as @bfreezy suggested that command line tools 12 was the issue for me when trying to install 2.1.10. Downgrading to 11.5. fixed install issues for me and I ran install with
RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.0)" rbenv install 2.1.10
(On OS X 10.15.6)
Also I found out before downgrading that there might issues and the command line tools are loaded from a wrong path as suggested below (I had wrong path for version 12 tools initially).
#1473 (comment)

@vemuri-nath
Copy link

@vemuri-nath vemuri-nath commented Oct 9, 2020

hii ,

does this fix works for 2.2.3 as well ??

@StephenSoft
Copy link

@StephenSoft StephenSoft commented Oct 14, 2020

rbenv install 2.1.10

Downloading openssl-1.0.2u.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16
Installing openssl-1.0.2u...

Installed openssl-1.0.2u to /Users/zhaofujun/.rbenv/versions/2.1.10

Downloading ruby-2.1.10.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.10.tar.bz2
Installing ruby-2.1.10...

WARNING: ruby-2.1.10 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 (Mac OS X 10.15.7 using ruby-build 20201005)

Inspect or clean up the working tree at /var/folders/cq/xmw2hj4d499c6zrcs7w_4wtw0000gn/T/ruby-build.20201014151416.69550.lZuVCh
Results logged to /var/folders/cq/xmw2hj4d499c6zrcs7w_4wtw0000gn/T/ruby-build.20201014151416.69550.log

Last 10 log lines:
make[2]: *** [ossl_pkcs7.o] Error 1
make[1]: *** [ext/openssl/all] Error 2
make[1]: *** Waiting for unfinished jobs....
compiling objspace_dump.c
installing default objspace libraries
linking shared-object objspace.bundle
linking shared-object nkf.bundle
13 warnings generated.
linking shared-object date_core.bundle
make: *** [build-ext] Error 2

@ksato0607
Copy link

@ksato0607 ksato0607 commented Oct 17, 2020

I had an exactly same issue. When I ran rbenv install 2.3.3, I had this error:

Last 10 log lines:
The Ruby openssl extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Configure options used:
  --prefix=/Users/username/.rbenv/versions/2.3.3
  --with-openssl-dir=/usr/local/opt/openssl@1.1
  --with-readline-dir=/usr/local/opt/readline
  CC=clang
  CFLAGS= -O3 -Wno-error=shorten-64-to-32 
  LDFLAGS=-L/Users/username/.rbenv/versions/2.3.3/lib 
  CPPFLAGS=-I/Users/username/.rbenv/versions/2.3.3/include 

From the post by @bfreezy, I learned that the version of Command Line Tools should not be 12. (Thank you so much for the information!) In fact, this is what I had

$ clang --version
Apple clang version 12.0.0 (clang-1200.0.32.2)

Therefore, I downgraded my Commond Line Tools version to 11 by following this post and I confirmed the version is downgraded.

$ clang --version
Apple clang version 11.0.3 (clang-1103.0.32.62)

Now I expect that rbenv install 2.3.3 will work, but it still failed with the following error. (--verbose just logs additional details)

$ rbenv install 2.3.3 --verbose
...
Downloading openssl-1.0.2u.tar.gz...
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  Referenced from: /usr/local/bin/curl
  Reason: image not found
/usr/local/bin/ruby-build: line 337:  3227 Abort trap: 6           curl -qsILf ${CURL_OPTS} "$1" 1>&4 2>&1
...
error: failed to download openssl-1.0.2u.tar.gz

BUILD FAILED (Mac OS X 10.15.6 using ruby-build 20201005)

It seems like there is an issue with curl, so I tried to reinstall it with the following command.

$ brew install --force curl
Updating Homebrew...
Warning: curl 7.72.0 is already installed, it's just not linked
You can use `brew link curl` to link this version.

As you can see above, in my case, I already had the latest version installed, but it was not linked.
Therefore, I updated the path of the curl like below

$ export PATH="/usr/local/opt/curl/bin:$PATH"

And tried rbenv install 2.3.3 again and it worked!! Hope it helps!!

@wyattbenno777
Copy link

@wyattbenno777 wyattbenno777 commented Dec 18, 2020

I was shown the same error.

For me it turned out that RVM and RBENV were both installed.
When I went into the directory RVM would change to the local ruby there, while globally I was using RBENV.

Uninstalled RVM and reentered the directory. Everything worked.

@mattneub
Copy link

@mattneub mattneub commented Feb 25, 2021

I had a similar problem. After unfortunately doing "brew upgrade" I ended up with openssl 1.1.1 installed and a bunch of broken already-installed rubies.

This isn't entirely germane to the current thread, but the same thing just happened to me — I said brew upgrade and all my rbenv rubies stopped working. For example, saying gem install failed; lots of other stuff went wrong too; but it all came down to a complaint about OpenSSL.

I ended up having to blow away all my rubies and install them again. Not a huge pain, but a pain nonetheless.

I find it very surprising that something can happen miles away (in brew) and rbenv can be crippled in this way.

@rtoledo-dev-ao3
Copy link

@rtoledo-dev-ao3 rtoledo-dev-ao3 commented Mar 5, 2021

readline.c:1781:37: error: use of undeclared identifier 'username_completion_function'; did you mean 'rl_username_completion_function'?

The biggest problem is the openssl 1.0 in M1 Apple. Trying install with

brew install rbenv/tap/openssl@1.0

or

arch -arm64 brew install rbenv/tap/openssl@1.0

Final result:

These open issues may also help:

brew install rbenv/tap/openssl@1.0 not working anymore https://github.com/rbenv/homebrew-tap/issues/1

So these commands aren't working too

RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)" rbenv install 2.3.8`

or

RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.0)" rbenv install 2.3.8

@gfguthrie
Copy link
Contributor

@gfguthrie gfguthrie commented Mar 5, 2021

The biggest problem is the openssl 1.0 in M1 Apple.

You're going to have to find your own solution for openssl 1.0 on Apple Silicon – they have no plans to backport building 1.0: openssl/openssl#12254 (comment)

There's probably an unofficial backport somewhere.

@ThomasKoppensteiner
Copy link

@ThomasKoppensteiner ThomasKoppensteiner commented Mar 15, 2021

Inspired by this solution the following worked for me:

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

Setting RUBY_CONFIGURE_OPTS or CFLAGS had no effect.

afinetooth added a commit to lemurheavy/coveralls-ruby that referenced this issue Apr 17, 2021
…d the differing versions of openssl between < 2.4 and >= 2.4 seems to be causing trouble when the matrix crosses this barrier. Potentially due to caching, and something that can be fixed, if we need to support 2.3, with extra scripting in our workflow to implement this solution: rbenv/ruby-build#1353 (comment)
@namratasaun
Copy link

@namratasaun namratasaun commented Aug 4, 2021

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

I am installing 2.3.4 and it's showing me openssl error shown below. (I have macos 11.5.1 and xcode 12.0.5)
image

@kornate
Copy link

@kornate kornate commented Aug 10, 2021

With Amazon Linux 2 on ARM/aarch you need to install openssl-devel.

@nicobrenner
Copy link

@nicobrenner nicobrenner commented Dec 22, 2021

Can confirm that gcc-6 + openssl@1.0 works (on MacOS BigSur 11.2.1, with homebrew):

brew install gcc@6
brew install rbenv/tap/openssl@1.0
RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.0)" CC=$(which gcc-6) rbenv install 2.0.0-p647

Also had Xcode 12 installed and if the above command didn't work, was going to downgrade to 11 to try again.

It seems like people using rvm are having the same issue and they've come up with a slightly different solution of passing an extra compiler flag (export optflags="-Wno-error=implicit-function-declaration"), see here: https://stackoverflow.com/a/64829129/7724157

Spoke too soon. After installation, running gem install bundler (or any gem) gives me the following error:

ERROR:  Loading command: install (LoadError)
	cannot load such file -- socket
ERROR:  While executing gem ... (NoMethodError)

Doing some searching it seems it's an issue with openssl... 🥲 back to square one.

Finally, this worked 😃:

export LDFLAGS="-L/usr/local/opt/openssl@1.0/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.0/include"
CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.0)" RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.0)" rbenv install 2.0.0-p647

@rbenv rbenv locked and limited conversation to collaborators Dec 29, 2021
@hsbt hsbt converted this issue into discussion #1883 Dec 29, 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