cannot load such file -- openssl (LoadError)
Asked Answered
S

15

59

In OS X in rvm how do I check if openssl is configured properly? I get the cannot load such file -- openssl (LoadError) And I have tried everything in Rails 3 - no such file to load -- openssl with no success.

Splinter answered 13/2, 2013 at 2:29 Comment(1)
latest solution for 2021: github.com/rvm/rvm/issues/4819#issuecomment-595644550Scabies
B
85

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.

Blossomblot answered 13/2, 2013 at 4:17 Comment(8)
I still get the same error. Also I've reinstalled ruby with sudo rvm install 1.9.3 --with-openssl-dir=$HOME/.rvm/usrSplinter
worked great, thanks! (I didn't need to do the rvm pkg remove step)Hilltop
I have been struggling with this install for 11+ hours. Yours are the only instructions that actually worked. THANK YOU!!!!Tigerish
I tried to get this working months ago and gave up. Came back and saw this and it fixed my issue. Thanks so much!Caloric
Thanks!! It just helped me install compass via ruby :DCrouton
is there a way to do this without homebrew (which rvm relies on)?Skimp
i read the error logs for rvm reinstall but it's saying it can't find openssl...Margarite
This is no longer a working solution under OS X Catalina. Seems Apple really did a number on the build tools that Ruby requires...Conspire
C
21

Many years later, the solution is changed because of brew upgrading, this works now:

# pull full brew git repo
git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" fetch --unshallow

# generate new brew tap repo
brew tap-new $USER/old-openssl

# extract openssl 1.0.2t forumlar to $USER/old-openssl
brew extract --version=1.0.2t openssl $USER/old-openssl

# install old openssl from $USER/old-openssl repo
brew install [email protected]

# reinstall ruby
rvm reinstall 2.3.4 --with-openssl-dir=`brew --prefix [email protected]`
Chemotropism answered 16/9, 2020 at 6:58 Comment(3)
I needed to add --autolibs=disable to rvm reinstall to prevent a brew update failure. Otherwise this works swimmingly. Thanks!Inadvisable
Thanks, this finally solved the problem for me! I had to remove the '--unshallow' from the first command otherwise I got the error: "fatal: --unshallow on a complete repository does not make sense"Levinson
This is the only thing that worked for me, I got MacOS 13 (March 2023)Consolation
D
17

This is what worked for me after wasting more than a day on this

brew reinstall [email protected]
brew unlink openssl && brew link openssl --force
echo 'export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"' >> ~/.zshrc   
export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/[email protected]/lib/pkgconfig"
rvm install ruby-2.7.6 --with-openssl-dir=/opt/homebrew/opt/[email protected] --verify-downloads 1
Deva answered 6/7, 2023 at 10:10 Comment(7)
Homebrew has changed location in new installs, meaning /usr/local should be changed to /opt/homebrew, as in /opt/homebrew/opt/openssl\@1.1/bin/.Misshapen
Thanks, I was previously using "rvm package" to install OpenSSL and this is much better.Rainy
thank you so much. after wasting 2 days i found this more helpful .Jacalynjacamar
This helped me! Along with the comment from @oligofren. Thank you so much :)) finally got a successful installMuth
Right now an Edit is pending, but one could make the answer work with both old and new versions of Homebrew by just substituting /usr/local/ with $( brew --prefix).Misshapen
Welcome to all!Deva
Working on 2024 Mac 14.5. After 3 hours of trying other "easier" solutionsSteele
H
13

This help me : https://gist.github.com/Irio/1496746

$ rvm pkg install openssl

$ rvm remove 1.9.3

$ rvm install 1.9.3 --with-openssl-dir=$rvm_path/usr
Homophonous answered 24/7, 2022 at 0:46 Comment(1)
Worked for me on Pop_OS 22.04 trying to get ruby-2.7.6 running. You can use reinstall instead of remove + install though, so all-in-all I ran: rvm pkg install openssl followed by rvm reinstall all --force --with-openssl-dir=$rvm_path/usrNorthumbrian
V
7

Install the openssl package

rvm pkg install openssl

Remove the Ruby installation you're using

rvm remove 2.3.3

And finally recompile Ruby with openssl

rvm install 2.3.3 --with-openssl-dir=$HOME/.rvm/usr
Venenose answered 12/3, 2023 at 23:0 Comment(1)
This seems like the simplest fix in 2023, if autolibs feature of rvm is not working for you.Gilding
Q
6

Try this.

rvm install ruby-2.0.0-preview1  --with-openssl-dir=$HOME/.rvm/usr --verify-downloads 1
Qualls answered 12/7, 2020 at 18:52 Comment(0)
S
4

I uninstalled everything (rvm, rails, ruby, etc) on my macbook.

Installed homebrew

Installed rvm

Ran rvm requirements run force

Ran rvm install rails

rails new sample_app

cd sample_app

Note: source 'https://rubygems.org' is present in Gemfile, openssl is required!

bundle install and it worked!

No need to specify: --with-openssl-dir=$HOME/.rvm/usr

Splinter answered 18/2, 2013 at 10:11 Comment(0)
N
4

To resolve this, install openssl (preferably using brew).

Update Xcode to the latest version and enable command line installations using it.

Reinstall rvm using rvm reinstall all

Note that rvm reinstall all --force will delete all your previous installations of binaries/pkgs done using rvm.

Needy answered 6/9, 2013 at 3:18 Comment(1)
If using rbenv this strategy also seems to work. The command is basically just to use the force option, rbenv install 3.1.2 --forceFrisket
K
1

Assuming ruby is already installed, do the following:

rvm cleanup all

rvm reinstall all --force
Ku answered 23/6, 2021 at 22:58 Comment(1)
Caution: rvm reinstall all --force can break your ruby installationsProphesy
H
1

somehow the openssl v3 package hinders installation of ruby v2.* . I got it working with these set of steps -

brew reinstall [email protected]
brew unlink openssl@3
brew unlink [email protected] && brew link [email protected] --force
echo 'export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"' >> ~/.zshrc   
export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/[email protected]/lib/pkgconfig"
rvm install ruby-2.7.6 --with-openssl-dir=/opt/homebrew/opt/[email protected]
Hallel answered 12/5 at 7:44 Comment(0)
B
0

I got the same error, and the error was fixed by opening new terminal session.

I am using frum ruby version manager.

Blurt answered 17/1, 2022 at 22:55 Comment(0)
D
0

Download openssl and install it on a local path.

export MACOSX_DEPLOYMENT_TARGET=10.9 ./Configure darwin64-x86_64-cc shared --prefix=$HOME/.local && make && make install

Then compile ruby with your open ssl compilation.

./configure --prefix=$HOME/.local --with-openssl-dir=$HOME/.local && make && make install
Drear answered 26/8, 2023 at 12:9 Comment(0)
C
0

I tried all the answer above but not working for me.

In my case, I am very sure that I have openssl, but it keep show the error said:

rspec cannot load such file -- openssl error Did you mean? openssl/ssl

After 3 days, I solved by add gem 'openssl' in the Gemfile.

Campbellite answered 11/9, 2023 at 7:58 Comment(0)
T
-1

gem install openssl
worked for me, but nothing has declared depending on the openssl, its weired

Tank answered 27/3, 2019 at 7:26 Comment(0)
E
-4

Following command solved my issue note 2.3.4 is the ruby version I am using, change as per your requirements

rvm reinstall 2.3.4 --with-openssl-dir=$rvm_path/usr

Make sure that $rvm_path is properly set, with command echo $rvm_path. If this path is empty, check if your home folder has .rvm folder.

In this case use

rvm reinstall 2.3.4 --with-openssl-dir=~/.rvm/usr
Elroyels answered 4/2, 2021 at 10:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.