'rvm can't compile ruby: fails openssl check
I'm trying to install ruby 2.7.6 on MacOS 11.6.1 using rvm
. I am specifying the location of a brew-installed openssl but the logs say that it isn't the right version. Everything looks OK to me. I am not sure how to troubleshoot further. Verbose details below.
I execute this command:
rvm install 2.7.6 --with-openssl-dir=`brew --prefix [email protected]`
The relevant part of the RVM log is
openssl:
Could not be configured. It will not be installed.
Check ext/openssl/mkmf.log for more details.
The relevant part of ext/openssl/mkmf.log
is:
checking for OpenSSL version >= 1.0.1 and < 3.0.0... -------------------- no
"gcc -I../../.ext/include/x86_64-darwin20 -I../.././include -I../.././ext/openssl -I/usr/local/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/libksba/include -I/usr/local/opt/readline/include -I/usr/local/opt/zlib/include -I/usr/local/opt/[email protected]/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -O2 -fno-common -pipe -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <openssl/opensslv.h>
4:
5: /*top*/
6: int conftest_const[(OPENSSL_VERSION_NUMBER >= 0x10001000L) ? 1 : -1];
/* end */
"gcc -I../../.ext/include/x86_64-darwin20 -I../.././include -I../.././ext/openssl -I/usr/local/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/libksba/include -I/usr/local/opt/readline/include -I/usr/local/opt/zlib/include -I/usr/local/opt/[email protected]/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -O2 -fno-common -pipe -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <openssl/opensslv.h>
4:
5: /*top*/
6: int conftest_const[(OPENSSL_VERSION_MAJOR >= 3) ? 1 : -1];
/* end */
--------------------
/Users/germuska/.rvm/src/ruby-2.7.6/ext/openssl/extconf.rb:111: OpenSSL >= 1.0.1, < 3.0.0 or LibreSSL >= 2.5.0 is required
/Users/germuska/.rvm/src/ruby-2.7.6/ext/openssl/extconf.rb:111:in `<top (required)>'
./ext/extmk.rb:214:in `load'
./ext/extmk.rb:214:in `block in extmake'
/Users/germuska/.rvm/src/ruby-2.7.6/lib/mkmf.rb:331:in `open'
./ext/extmk.rb:210:in `extmake'
./ext/extmk.rb:572:in `block in <main>'
./ext/extmk.rb:568:in `each'
./ext/extmk.rb:568:in `<main>'
Solution 1:[1]
Upon closer review, I realized I had an openssl
directory (containing version 3) in /usr/local/include
and that was on the include path ahead of the directory I specfied with the --with-openssl-dir
option.
I fixed it by renaming /usr/local/include/openssl
to /usr/local/include/openssl_hideme
; after that, the extension compiler found the version I wanted.
I would have guessed that includes on the command line would be put in front of the path, but lesson learned.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Joe Germuska |