ruby-build: Cannot install Ruby versions < 2.4 because of openssl@1.1 dependency
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?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 31
- Comments: 50 (13 by maintainers)
Links to this issue
Commits related to this issue
- Fixing minor issues in mac setup script - `caskroom/cask` no longer needs to be tapped in newer versions of homebrew: https://stackoverflow.com/a/58337898 - Resolving openssl version conflict when... — committed to policygenius/laptop by deleted user 5 years ago
- env - Environment variable for rbenv installed using brew - https://github.com/rbenv/ruby-build/issues/1353#issuecomment-537749304 - https://github.com/rbenv/ruby-build/issues/1353#issuecomment-57341... — committed to qrg/dotfiles by qrg 4 years ago
- Bump up .ruby-version and remove 2.3 from build matrix. 2.3 is EOL and the differing versions of openssl between < 2.4 and >= 2.4 seems to be causing trouble when the matrix crosses this barrier. Pote... — committed to lemurheavy/coveralls-ruby by afinetooth 3 years ago
@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: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): https://github.com/rbenv/ruby-build/issues/1353#issuecomment-573414540
(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)
Thanks @mislav . One small tweak and it worked for me
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
@12masta you have to install it first from the
rbenv
tap:brew install rbenv/tap/openssl@1.0
Inspired by this solution the following worked for me:
Setting
RUBY_CONFIGURE_OPTS
orCFLAGS
had no effect.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:
Before executing this, you might want to print a list of the files you’re going to be working on:
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.
@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.
@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
These don’t
I’m still getting this error…
$ RUBY_CONFIGURE_OPTS=“–with-openssl-dir=/usr/local/opt/openssl” rbenv install 1.9.3-p194 ruby-build: using libyaml from homebrew Downloading ruby-1.9.3-p194.tar.bz2… -> https://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.bz2 Installing ruby-1.9.3-p194…
WARNING: ruby-1.9.3-p194 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 (OS X 10.14.5 using ruby-build 20200224-6-gd8019fe)
Inspect or clean up the working tree at /var/folders/_w/98n31_kn03qfjt51p2hmrfqh0000gp/T/ruby-build.20200318004702.63722.sGWK6N Results logged to /var/folders/_w/98n31_kn03qfjt51p2hmrfqh0000gp/T/ruby-build.20200318004702.63722.log
Last 10 log lines: compiling regerror.c compiling regexec.c compiling regparse.c regparse.c:582:15: error: implicit conversion loses integer precision: ‘st_index_t’ (aka ‘unsigned long’) to ‘int’ [-Werror,-Wshorten-64-to-32] return t->num_entries; ~~~~~~ ~
^~~~~~~~~ 1 error generated. make: *** [regparse.o] Error 1 make: *** Waiting for unfinished jobs… 13 warnings generated.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). https://github.com/rbenv/ruby-build/issues/1473#issuecomment-696765978@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?For anyone other MacOS users and Swift lang users where
doesn’t work. Check and see if your global environment is using the system Swift lang or a Toolchain build. Setting
swiftenv global system
did the trick.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)
I had an exactly same issue. When I ran
rbenv install 2.3.3
, I had this error: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
Therefore, I downgraded my Commond Line Tools version to 11 by following this post and I confirmed the version is downgraded.
Now I expect that
rbenv install 2.3.3
will work, but it still failed with the following error. (--verbose
just logs additional details)It seems like there is an issue with
curl
, so I tried to reinstall it with the following command.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
And tried
rbenv install 2.3.3
again and it worked!! Hope it helps!!This seems to have worked for me! THANK YOU @mislav
@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 theopenssl
that is needed for 2.3.7.