Skip to content

Instantly share code, notes, and snippets.

@khun84
Last active May 27, 2021 02:53
Show Gist options
  • Save khun84/8f3a1cddfe7192b87fc4630e0ec86a88 to your computer and use it in GitHub Desktop.
Save khun84/8f3a1cddfe7192b87fc4630e0ec86a88 to your computer and use it in GitHub Desktop.
How to install Ruby 2.3.1 using RVM and OpenSSL 1.0.2

Guides

  1. Uninstall and install openssl version 1.0.2. As openssl v1.0.2 is no longer available, I have extracted openssl v1.0.2 and make it available at https://github.com/khun84/homebrew-repo/
brew uninstall --force --ignore-dependencies openssl
brew install khun84/homebrew-repo/openssl
brew cleanup # in case it fails due to permission denied, it can be due to the symlink to be removed is pointing to a non-exist file/directory. Just create the corresponding file or directory and run this command again
  1. After OpenSSL installation, check it using pkg-config --libs openssl. You should see something like -L/usr/local/Cellar/openssl/1.0.2t/lib -lssl -lcrypto

  2. Remove your rvm ruby 2.3.1 if you have not by rvm remove 2.3.1

  3. Install rvm ruby 2.3.1 by PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig rvm reinstall 2.3.1 --with-openssl-lib=/usr/local/opt/openssl --with-openssl-include=/usr/local/opt/openssl/include/openssl. Verify you have the directory specified by PKG_CONFIG_PATH, --with-openssl-lib and --with-openssl-include before you run this command! Otherwise you will need to redo Step 3 and Step 4 again.

Notes

  1. If it still doesn't work, may try brew switch openssl 1.0.2t. Here I already have openssl version 1.0.2t installed

Reference

  1. https://mentalized.net/journal/2019/09/13/ruby-2-3-rvm-and-openssl-1-0/
@khun84
Copy link
Author

khun84 commented Oct 5, 2020

Actually there might be not necessary to reinstall openssl. The root of the problem is that rvm is not able to compile a specific ruby with the correct openssl dependency.

So if we already have the desired openssl version install, which normally resides in /usr/local/Cellar/openssl/{version} (if you install it via homebrew), we can just install ruby with these flags PKG_CONFIG_PATH=/usr/local/Cellar/openssl/{version}/lib/pkgconfig rvm reinstall 2.3.1 --with-openssl-lib=/usr/local/Cellar/openssl/{version} --with-openssl-include=/usr/local/Cellar/openssl/{version}/include/openssl

@khun84
Copy link
Author

khun84 commented May 27, 2021

There's another fix from SO by just changing the file symlink target, provided the openssl 1.0.2t already installed. Might need to install this openssl version again if brew remove it during brew update.

Reference:

  1. https://stackoverflow.com/questions/59006602/dyld-library-not-loaded-usr-local-opt-openssl-lib-libssl-1-0-0-dylib

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