60

Using rvm I upgraded my ruby to 1.9.3-p392, also added 2.0.0, anytime I try to use this version when I run my bundle command I get this error.

Could not load OpenSSL.
You must recompile Ruby with OpenSSL support or change the sources in your Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL using RVM are
available at rvm.io/packages/openssl.

I have followed several different instructions on how to fix this. I have tried removing the version and installing it with the rvm options

--with-openssl-dir=$HOME/.rvm/usr

I have installed OpenSSL with rvm, and macports. Both have not helped the problem. I even changed the file location of the ssl cert using this:

export SSL_CERT_FILE=/Users/DarkLord/.rvm/usr/ssl/cert.pem

No matter what I do I continue to get the error. Can someone please help me fix this?

jww
  • 97,681
  • 90
  • 411
  • 885
covard
  • 1,667
  • 2
  • 18
  • 33
  • I had this same issue on Ubuntu; this seemed to resolve the problem: https://github.com/rvm/rvm/issues/4357#issuecomment-381561492 – GDP2 May 01 '22 at 21:58

17 Answers17

85

This works for me:

rvm get stable

brew install libyaml

rvm pkg install openssl

rvm install ruby-2.0.0 --with-openssl-dir=$HOME/.rvm/usr

rvm use ruby-2.0.0

All credits go to https://coderwall.com/p/tptocq

Anh Nguyen
  • 5,245
  • 1
  • 20
  • 18
  • 4
    `rvm pkg install openssl` incurred a deprecation from rvm version 1.24.7. If you type `rvm autolibs` it will show a help screen with some alternatives. Personally I used the option #4 which was `rvm autolibs homebrew` then `rvm uninstall 2.0.0-p353` then `rvm install ruby-2.0.0-p353 --with-openssl-dir=$HOME/.rvm/usr`. This didn't quite work, but it generated a .log file with some instructions to do brew doctor and unlink a few libs. Then re-running that last rvm install command worked. – Purplejacket Dec 03 '13 at 03:12
54

This helps me install 1.9.3-head on Mac:

rvm get latest    
brew install openssl    
rvm reinstall 1.9.3-head --with-openssl-dir=`brew --prefix openssl`
virtax
  • 549
  • 4
  • 2
13

In my case after:

 1. brew install openssl
 2. rvm install ruby-2.6.0

bundle install failed with this error. The problem was that openssl was globally set so I had to install the new ruby version by setting the openssl directory explicitly.

So what I had to do was:

 1. rvm reinstall ruby-2.6.0 --with-openssl-dir=/usr/local/opt/openssl
 2. rvm reload

Assuming that usr/local/opt/openssl is where it is installed.

After that bundle install ran successfully.

Warning when I tried this command with this path /usr/local like some answers suggested, it didn't work.

dktistakis
  • 451
  • 4
  • 7
  • 1
    Also if you only run `rvm reinstall ruby-2.2.9` without the `--with-openssl-dir=` section then that won't work! – alexventuraio Apr 23 '19 at 22:37
  • 1
    And if you do not know where is your openssl path you can get it by running `brew --prefix openssl`. – alexventuraio Apr 23 '19 at 22:40
  • 6
    Combining the answers, I recommend ```rvm reinstall ruby-2.3.7 --with-openssl-dir=`brew --prefix openssl` ``` as the final solution. – genkilabs May 16 '19 at 21:40
10

The new way to do it, according to a comment by @Purplejacket above, is the following:

rvm autolibs homebrew
rvm install 2.1.1
rvm use 2.1.1

It's much easier.

thekingoftruth
  • 1,711
  • 1
  • 25
  • 24
9

To get this working again I had to install homebrew and move my mac ports out of the way. Then do the following after removing 1.9.3-p392 and 2.0.0-p0:

rvm get head --autolibs=3
rvm install 1.9.3 --with-opt-dir=/usr/bin
rvm install 2.0.0

There was something not working with my mac ports and openssl and make and configure. This was the only way I was able to get rvm to install ruby again with out getting openssl issues or make/configure issues.

covard
  • 1,667
  • 2
  • 18
  • 33
7

In my case:

Problem: After installing ruby-2.3.1, I ran the command bundle install and then the error occurred.

Solution:

  • I first installed OpenSSL on my machine. $ brew install openssl
  • And then, reinstalled the ruby version I require (2.3.1) with the openssl.

    $ rvm reinstall 2.3.1 --with-openssl-dir=/usr/local/opt/openssl

And this solved my problem!

Solomon
  • 81
  • 1
  • 4
4

According to the following question: How to tell which openssl lib is actually being used by an RVM-installed ruby

It seems that the options --with-openssl-dir=... is no longer valid as of Ruby 1.9.3. I tried

rvm install 1.9.3 --with-opt-dir=/usr/local --with-openssl

and it worked.

Community
  • 1
  • 1
LiAh Sheep
  • 81
  • 2
3

macOS Catalina

brew install rbenv/tap/openssl@1.0
rvm reinstall 2.3.8 --with-openssl-dir=/usr/local/opt/openssl@1.0
PGill
  • 3,373
  • 18
  • 21
3

Specific case for ruby version 3.0.3 or above

By default for brew and system and autolibs OpenSSL version is 3. Ruby 3.0.3 does not work with OpenSSL version 3 and ruby build silently ignores OpenSSL.

To build ruby properly use build options with OpenSSL 1 like this:

PKG_CONFIG_PATH=/usr/local/opt/openssl@1.1/lib/pkgconfig rvm reinstall 3.0.3 --with-openssl --with-openssl-lib=/usr/local/opt/openssl@1.1/lib --with-openssl-include=/usr/local/opt/openssl@1.1/include

Where path variables may be another - check your system.

Thanks to article Ruby 3.0.3 with OpenSSL using MacPorts and RVM

oklas
  • 7,935
  • 2
  • 26
  • 42
2

The following steps worked for me.

First ensure openssl is installed by running brew install openssl, then reinstall the ruby version using rvm, but this time around, you have to pass the with-opt-dir flag pointing to the location where openssl was installed on your machine (use command which openssl to find this location).

rvm install 1.9.3-p392 --with-openssl-dir=/usr/local/opt/openssl
Dinobi
  • 21
  • 5
2

Fix which worked for me

rvm install 3.0.3 --with-openssl-dir=/opt/homebrew/etc/openssl@1.1

PS. Find the correct openssl location in your machine and install ruby pointing to that path like above, mentioning the brew installed openssl@3 path doesnot work.

Logesh Paul
  • 7,600
  • 3
  • 26
  • 23
  • This didn't quite work, I had to change the path to `/opt/homebrew/opt/openssl@1.1`. The `etc` folder doesn't have `lib` or `include`. – jwadsack May 06 '23 at 20:50
1

On macOS 10.14, Ruby 2.5.3, and OpenSSL 1.0.2n this worked for me:

./configure --with-openssl --with-openssl-dir=/usr/local/ssl

but I was only trying what the error messages were telling me:

*** Following extensions are not compiled:
openssl:
    Could not be configured. It will not be installed.
    /Users/brian/Desktop/Ruby/ruby-2.5.3/ext/openssl/extconf.rb:97: OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed.
    Check ext/openssl/mkmf.log for more details.
*** Fix the problems, then remove these directories and try again if you want.
make[1]: *** [note] Error 1
brian d foy
  • 129,424
  • 31
  • 207
  • 592
1

I encountered this issue when working on a Ruby 2.2.3 application.

I had previously uninstalled the MySQL database server on my machine, since I did not need it. However, I still needed the mysql2 gem since my application was connecting to another application's MySQL database to pull data.

However, when I try to run the bundle command I get the error:

Could not load OpenSSL. You must recompile Ruby with OpenSSL support or change the sources in your Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL using RVM are available at rvm.io/packages/openssl.

Here's how I solved it:

The issue was caused by removing the libssl-dev library when I was uninstalling the MySQL database server on my machine and its libraries.

First I ran the command below to reinstall ruby since I installed it using rvm:

rvm reinstall ruby-2.2.3

This raised an error:

Making gemset ruby-2.2.3 pristine............................................./- .'command gem pristine --extensions mysql2 --version 0.5.3' failed, you need to fix these gems manually. . Error running '__rvm_with ruby-2.2.3 gemset_pristine', please read /home/promisepreston/.rvm/log/1630094455_ruby-2.2.3/gemset.pristine-ruby-2.2.3.log

Next, I tried to install the mysql2 gem:

gem install mysql2

Then I ran into this error:

Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. mysql client is missing. You may need to 'sudo apt-get install libmariadb-dev', 'sudo apt-get install libmysqlclient-dev' or 'sudo yum install mysql-devel', and try again.

Finally, I installed the mysql client library using the command:

sudo apt-get install libmysqlclient-dev

Note: This also installs the libssl-dev library alongside.

And everything worked fine.

That's all.

Promise Preston
  • 24,334
  • 12
  • 145
  • 143
0

That's what helped me:

rvm reinstall 2.5

brew tap raggi/ale
brew install openssl-osx-ca
brew services start openssl-osx-ca

Found this solution here: https://github.com/raggi/openssl-osx-ca#readme

0

I specified a more recent Ruby version in my Gemfile, then ran bundle install. All good now.

0

I got this to work on Ubuntu 22.04 by doing:

rvm pkg install openssl

...and adding --with-openssl-dir=$HOME/.rvm/usr to the rvm install command.

This doesn't seem particularly OS-specific and might work on Mac OS as well.

Keith Bennett
  • 4,722
  • 1
  • 25
  • 35
-1

I don't use rvm, and I don't want to. I had to install asdf in order to resolve what I used to be able to do with just homebrew & ruby.

Following this guide is the only thing that worked for me after following dozens of suggestions. I had to install asdf and update my .zshrc to include the following at the end of the doc:

eval "$(rbenv init - zsh)"

I'm on an Intel Mac running Monterey 12.2.1.

Kreidol
  • 180
  • 1
  • 16