Skip to content

Instantly share code, notes, and snippets.

@ajkovar
Last active November 20, 2020 03:17
Show Gist options
  • Save ajkovar/9cf887eface1d8eea1a710bc1209af8c to your computer and use it in GitHub Desktop.
Save ajkovar/9cf887eface1d8eea1a710bc1209af8c to your computer and use it in GitHub Desktop.
ruby-2.3.0 install issues
rvm install ruby-2.3.0

this gave this error:

more /Users/alex/.rvm/log/1600191501_ruby-2.3.0/rubygems.install.log
[2020-09-15 12:46:13] /Users/alex/.rvm/rubies/ruby-2.3.0/bin/ruby
current path: /Users/alex/.rvm/src/rubygems-3.0.8
GEM_HOME=/Users/alex/.rvm/gems/ruby-2.7.1
PATH=/usr/local/opt/coreutils/bin:/usr/local/opt/pkg-config/bin:/usr/local/opt/libtool/bin:/usr/local/opt/automake/bin:/usr/local/opt/autoconf/bin:/Users/alex/.cabal/bin:/Users/alex/.ghcup/bin:/Users/alex/.nvm/versions/node/v8.11.3/bin:/Users/alex/.nix-profile/bin:/Users/alex/bin:/Users/alex/.rvm/gems/ruby-2.7.1/bin:/Users/alex/.rvm/gems/ruby-2.7.1@global/bin:/Users/alex/.rvm/rubies/ruby-2.7.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/Library/Apple/usr/bin:/Users/alex/.rvm/bin
GEM_PATH=/Users/alex/.rvm/gems/ruby-2.7.1:/Users/alex/.rvm/gems/ruby-2.7.1@global
command(7): env GEM_HOME=/Users/alex/.rvm/gems/ruby-2.3.0@global GEM_PATH= /Users/alex/.rvm/rubies/ruby-2.3.0/bin/ruby -d /Users/alex/.rvm/src/rubygems-3.0.8/setup.rb --no-document
Exception `LoadError' at /Users/alex/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems.rb:1241 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /Users/alex/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems.rb:1250 - cannot load such file -- rubygems/defaults/ruby
Exception `LoadError' at /Users/alex/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55 - cannot load such file -- did_you_mean
/Users/alex/.rvm/src/rubygems-3.0.8/lib/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- openssl (LoadError)
    from /Users/alex/.rvm/src/rubygems-3.0.8/lib/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Users/alex/.rvm/src/rubygems-3.0.8/lib/rubygems/specification.rb:2481:in `to_ruby'
    from /Users/alex/.rvm/src/rubygems-3.0.8/lib/rubygems/commands/setup_command.rb:405:in `install_default_bundler_gem'
    from /Users/alex/.rvm/src/rubygems-3.0.8/lib/rubygems/commands/setup_command.rb:167:in `execute'
    from /Users/alex/.rvm/src/rubygems-3.0.8/lib/rubygems/command.rb:321:in `invoke_with_build_args'
    from /Users/alex/.rvm/src/rubygems-3.0.8/lib/rubygems/command_manager.rb:184:in `process_args'
    from /Users/alex/.rvm/src/rubygems-3.0.8/lib/rubygems/command_manager.rb:148:in `run'
    from /Users/alex/.rvm/src/rubygems-3.0.8/lib/rubygems/gem_runner.rb:59:in `run'

this suggested doing this:

rvm pkg install openssl

That didn't work.. and it seems this optin is actually outdated. So then followed this, which uses the newer option of 'autolibs', and which had me do this:

rvm get stable
rvm autolibs enable
rvm reinstall all --force

Reinstalling for all versions of ruby seems unnecessary but some of the versions did work. The 2.3 version, however, did not...

After investigating this option more, it seems that what the autolibs option does is it detects what pakage manager you are using (homebrew in the case of mac) and it attempts to install packages (such as open_ssl) in the case that you don't have them installed. Considering that open_ssl was already installed, it seems more obvious why this wouldn't have helped.

This well upvoted suggestion:

rvm reinstall ruby-2.3.0 --with-openssl-dir=/usr/local/opt/openssl@1.1

Didn't work either..

Also attempted this, which recommended adding the bin path of openssl to the PATH variable:

export PATH=$(brew --prefix openssl)/bin:$PATH
echo "export PATH=$(brew --prefix openssl)/bin:$PATH" >> ~/.bash_profile

Also.. didn't work

I tried to modify the previuos command based no what was suggested by this one by tacking /bin at the end:

rvm reinstall ruby-2.3.0 --with-openssl-dir=/usr/local/opt/openssl@1.1/bin

But no luck.

This suggested installing a different version of ruby gems:

rvm reinstall ruby-2.3.0 --with-openssl-dir=brew --prefix openssl --rubygems 2.6.11

Which worked... but then gem install failed with the same error:

gem install bundle
ERROR:  While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

I also noticed this error about java/homebrew cask, which comes right after output related to openssl:

rvm reinstall ruby-2.3.0 --with-openssl-dir=/usr/local/opt/openssl@1.1/bin
Warning! PATH is not properly set up, /Users/alex/.rvm/gems/ruby-2.3.0/bin is not at first place.
         Usually this is caused by shell initialization files. Search for PATH=... entries.
         You can also re-add RVM to your profile by running: rvm get stable --auto-dotfiles
         To fix it temporarily in this shell session run: rvm use ruby-2.3.0
         To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.
ruby-2.3.0 - #removing src/ruby-2.3.0..
ruby-2.3.0 - #removing rubies/ruby-2.3.0..
Checking requirements for osx.
Installing requirements for osx.
Updating system............
Installing required packages: openssl.
Error: Cask 'java' is unreadable: undefined method `undent' for #<String:0x00007fc84b27a860>

Which may or may not be related. This page recommended updating/upgrading homebrew/homebrew cask:

brew update && brew upgrade && brew cask upgrade

This resulted in the same error. This comment recommended just deleting the java cask directory manually:

rm -r "$(brew --prefix)/Caskroom/java"

This did, in fact, fix the error with homebrew.. but ruby gems for ruby 2.3 still is not installing due to this issue with openssl.

I found this which suggested setting some env variables prior to installing ruby. First running:

brew info openssl

Then copying the env variables from there:

export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

This seemed to acually do something.. but it still failed.. this time with a different error:

/usr/local/Cellar/openssl@1.1/1.1.1g/include/openssl/asn1_mac.h:10:2: error: "This file is obsolete; please update your software."
#error "This file is obsolete; please update your software."
 ^
In file included from ossl_pkcs7.c:10:
In file included from ./ossl.h:221:
./openssl_missing.h:78:31: error: too many arguments provided to function-like macro invocation
EVP_MD_CTX *EVP_MD_CTX_create(void);
                              ^
/usr/local/Cellar/openssl@1.1/1.1.1g/include/openssl/evp.h:541:10: note: macro 'EVP_MD_CTX_create' defined here
# define EVP_MD_CTX_create()     EVP_MD_CTX_new()
         ^
In file included from ossl_pkcs7.c:10:
In file included from ./ossl.h:221:
./openssl_missing.h:82:22: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
                     ^
./openssl_missing.h:82:6: error: conflicting types for 'EVP_MD_CTX_reset'
void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
     ^
/usr/local/Cellar/openssl@1.1/1.1.1g/include/openssl/evp.h:542:34: note: expanded from macro 'EVP_MD_CTX_init'
# define EVP_MD_CTX_init(ctx)    EVP_MD_CTX_reset((ctx))
                                 ^
/usr/local/Cellar/openssl@1.1/1.1.1g/include/openssl/evp.h:539:5: note: previous declaration is here
int EVP_MD_CTX_reset(EVP_MD_CTX *ctx);
    ^
In file included from ossl_pkcs7.c:10:
In file included from ./ossl.h:221:
./openssl_missing.h:90:25: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
                        ^
./openssl_missing.h:90:6: error: conflicting types for 'EVP_MD_CTX_free'
void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
     ^
/usr/local/Cellar/openssl@1.1/1.1.1g/include/openssl/evp.h:543:34: note: expanded from macro 'EVP_MD_CTX_destroy'
# define EVP_MD_CTX_destroy(ctx) EVP_MD_CTX_free((ctx))
                                 ^
/usr/local/Cellar/openssl@1.1/1.1.1g/include/openssl/evp.h:540:6: note: previous declaration is here
void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
     ^
In file included from ossl_pkcs7.c:10:
In file included from ./ossl.h:235:
./ossl_pkey.h:45:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if HAVE_BN_GENCB
    ^
./ossl_pkey.h:44:23: 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)
                      ^
./ossl_pkey.h:45:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
./ossl_pkey.h:44:60: 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)
                                                           ^
./ossl_pkey.h:45:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
./ossl_pkey.h:44: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)
                                                                                                      ^
5 warnings and 4 errors generated.
make[2]: *** [ossl_pkcs7.o] Error 1
make[1]: *** [ext/openssl/all] Error 2
make[1]: *** Waiting for unfinished jobs....
compiling objspace_dump.c
linking shared-object objspace.bundle
linking shared-object date_core.bundle
linking shared-object nkf.bundle
make: *** [build-ext] Error 2
++ return 2

The above errors seem to indicate that ruby is referencing outdated files within the openssl library. This recommended using the --disable binary option to force it to recompile using the the current version of open_ssl that is installed on the system. So gave that a shot:

rvm reinstall ruby-2.3.0 --disable-binary --with-openssl-dir=/usr/local/opt/openssl@1.1

But that also didn't work. After reading through that issue more, it seems that should have already been corrected in the newer versions of rvm.

Update after a few months

Installing ruby 2.7.1 via rvm triggered another openssl upgrade:

Upgrading 1 outdated package:
openssl@1.1 1.1.1g -> 1.1.1h
==> Upgrading openssl@1.1 1.1.1g -> 1.1.1h 
==> Downloading https://homebrew.bintray.com/bottles/openssl%401.1-1.1.1h.catalina.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/4e5357c0cfd55cfa4ef0b632c6fc9f49d39337dd070dc12d3c862e28bd28f079?response-content-disposition=attachment%3Bfilename%3D%22o
######################################################################## 100.0%
==> Pouring openssl@1.1-1.1.1h.catalina.bottle.tar.gz

That seemed to work without any problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment