ruby 2.0 rails gem install error cannot load such file -- openssl
You have to install OpenSSL first and recompile ruby again:
RVM:
rvm pkg install openssl
rvm reinstall ruby-2.0.0-p0 --with-gcc=gcc-4.7 --with-openssl-dir=$rvm_path/usr
Installing Ruby on Rails from Source - cannot load such file -- openssl
I managed to solve the problem by doing the following. The main problem was the step I followed to compile openssl itself.
Since I am on a 64 bit machine, I had to configure openssl by running the following command first
./configure --prefix=/Users/user/Applications/openssl darwin64-x86_64-cc
./make
./make install
And recompile ruby as such
./configure --prefix=/Users/user/Applications/ruby2 --with-openssl-dir=/Users/user/Applications/openssl
./make
./make install
Note: Even though while compiling ruby it might say... the option --with-openssl-dir is not valid or does not exist, ignore that.
Installing ruby-2.1.2: Cannot load such file -- openssl (LoadError)
Ruby <2.4 is incompatible with OpenSSL 1.1 (e.g see https://github.com/rbenv/ruby-build/issues/1353).
Just a hunch, but if you're using Mac + Homebrew, OpenSSL 1.0 was recently deleted, so anything along the lines of brew upgrade openssl
would trash that.
There are several options to deal with this:
- I have older Rubies via
asdf
installed with LibreSSL (which may be safer anyway, see https://security.stackexchange.com/questions/112545/what-are-the-main-advantages-of-using-libressl-in-favor-of-openssl):
$ openssl
OpenSSL> version
LibreSSL 2.8.3
- Compile and link your own OpenSSL 1.0 (or then set compiler flags as environment variables when building Ruby -- https://rvm.io/rubies/installing)
- See if your system's package manager allows you to access openssl 1.0 and install with that (was helping a coworker with this recently and we weren't able to find a good keg for homebrew at this time, unfortunately)
There might be something less convoluted than that; if someone has ideas, please feel free to comment or give an alternate answer.
EDIT
I personally ran into this issue with some other software and discovered that this fixed it, since the old SSL version was sitting around still:
brew switch openssl 1.0.2s
Should work so long as Homebrew doesn't "helpfully" clean that out for me.
cannot load such file -- openssl (LoadError)
Check what rubies are installed:
rvm list
Then make sure to use one of the installed rubies:
rvm use 1.9.3-p327
And test if openssl
is available:
ruby -ropenssl -e "puts :OK"
It will print OK
if openssl
is enabled, otherwise you will get exception
In case of exception =>
UPDATE:
new version of rvm has improved automation support:
rvm get stable
rvm autolibs enable
rvm reinstall all --force
OLD:
run:
rvm requirements run force
rvm pkg remove
Followed by:
rvm reinstall all --force
This instruction is not OSX specific, it will work on all platforms, although on OSX it will work best with HomeBrew, when it's not installed only list of required software will be shown and you need to install it manually.
Error installing gems: cannot load such file -- zlib
The following worked for me:
brew install homebrew/dupes/zlib
rvm reinstall 2.2.2 --with-zlib-dir=/usr/local/Cellar/zlib/1.2.8
Hope this helps anyone else who runs into it.
Related Topics
Ruby Block and Unparenthesized Arguments
Save Image from Url by Paperclip
How to Split (Chunk) a Ruby Array into Parts of X Elements
How to Convert a String Object into a Hash Object
Difference Between Include and Extend in Ruby
Ruby: How to Post a File Via Http as Multipart/Form-Data
Do..End VS Curly Braces For Blocks in Ruby
How to Get a Random Number in Ruby
Where and How Is the _ (Underscore) Variable Specified
Rails 4: List of Available Datatypes
Is There Any Wisdom Behind "And", "Or" Operators in Ruby
What Does @@Variable Mean in Ruby
What Does the Question Mark At the End of a Method Name Mean in Ruby