Amod Pandey
Amod Pandey

Reputation: 1396

puma gem - Failed to build gem native extension

I was getting the following error while installing puma gem

    $ gem install puma
    Fetching: puma-2.11.2.gem (100%)
    Building native extensions.  This could take a while...
    ERROR:  Error installing puma:
    ERROR: Failed to build gem native extension.

    ruby extconf.rb
    checking for BIO_read() in -lcrypto... no
    checking for BIO_read() in -llibeay32... no
    *** extconf.rb failed ***

Upvotes: 41

Views: 31961

Answers (16)

Miguel Estrada
Miguel Estrada

Reputation: 1

This works for me

bundle config build.puma --with-openssl-dir=$HOME/.rvm/usr/include

then

bundle install

Upvotes: 0

Denis S Dujota
Denis S Dujota

Reputation: 611

This is an old topic, but nothing here helped, so I am sharing how i fixed this, since it took a lot of digging a bit of reading.

re-isntall open ssl: brew reinstall openssl

get the path to the installed openssl: brew --prefix openssl

finally, reinstall puma with the correct path gem install puma -v '5.6.7' -- --with-openssl-dir=/path/to/openssl

finally if you using bundle, you can go ahead and bundle install/update

Upvotes: 0

matsko
matsko

Reputation: 22223

I had to do this beforehand:

sudo apt-get install libgmp3-dev

Upvotes: 4

Deepak Mahakale
Deepak Mahakale

Reputation: 23711

For puma 6.0 and above use the following

PUMA_DISABLE_SSL=1 gem install puma -v "6.2.1"

If you're facing issue with bundle install

Run

export PUMA_DISABLE_SSL=1 

bundle install

Upvotes: 3

Kunsang Dorjee
Kunsang Dorjee

Reputation: 39

Install these packages.

apt-get install openssl ruby-openssl libssl-dev

Upvotes: 0

kometen
kometen

Reputation: 7852

Not my answer but this helped me install puma on macos (big sur) since there were warnings when building puma.

The command that I used is this:

gem install puma -- --with-cflags="-Wno-error=implicit-function-declaration"

Upvotes: 23

Amod Pandey
Amod Pandey

Reputation: 1396

The gem is looking for ssl libraries. So we have to provide the path to the lib containing the ssl lib

e.g. /usr/share/openssl

In my case the the ssl lib "libcrypto" was in /usr/local/lib. So let's pass /usr/local to it (excluding lib word).

For gem install

gem install puma -- --with-opt-dir=/usr/local

For bundle install

bundle config build.puma --with-opt-dir=/usr/local
bundle install

notice the name build.puma. where puma is the name of the gem.

The build config command adds the following to ~/.bundle/config

---
BUNDLE_BUILD__PUMA: "--with-opt-dir=/usr/local"

Upvotes: 6

AkashP
AkashP

Reputation: 706

Have you tried

DISABLE_SSL=true gem install puma

Specify the version if you have version specific requirement like:

DISABLE_SSL=true gem install puma -v version_number

Upvotes: 18

ykadaru
ykadaru

Reputation: 1144

Run brew info openssl and follow the instructions there. Do not try to --force link the latest openssl with the one that comes installed with OSX by default. (0.9.8)

Specifically it'll ask you to add the Homebrew version of openssl (should be 1.0.2 as of this date) into your $PATH.
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

Note: Make sure to remove any export PATH lines from the bash_profile, since this line above exports it for you appending the rest of the $PATH variable to the end. To view the bash profile use vi ~/.bash_profile

This fixed the problems for installing ruby gems that require compilation. (Puma in this case)

Upvotes: 1

Victor
Victor

Reputation: 947

libssl1.0-dev installing helped to me. Try

apt-get install libssl1.0-dev

and then

gem install puma

Upvotes: 19

Bloomberg
Bloomberg

Reputation: 2367

It could be an open ssl error

gem install puma -v 2.11.2 -- --with-opt-dir=/usr/local/opt/openssl

Upvotes: 9

Beartech
Beartech

Reputation: 6421

I'm on OS X 10.12.4 and the comment @mahi added worked for me:

gem install puma -v '3.6.0' -- --with-opt-dir=/usr/local/opt/openssl

Upvotes: 41

morgler
morgler

Reputation: 1809

When using bundler and homebrew:

$ bundle config build.puma --with-cppflags=-I$(brew --prefix openssl)/include
$ bundle install

I copied and adapted this answer from Lloeki here: https://stackoverflow.com/a/31516586/704499

Upvotes: 8

Konstantin Rudy
Konstantin Rudy

Reputation: 2257

I had similar issue on OSx El Capitan. In order to fix the issue I had to do:

brew install openssl
brew link --force openssl

Upvotes: 13

Jon Snow
Jon Snow

Reputation: 11892

Try the following

gem install puma -- --with-cppflags=-I/usr/local/opt/openssl/include
bundle install

You can also specify the gem version, like the following:

gem install puma -v '2.11.3' -- --with-cppflags=-I/usr/local/opt/openssl/include

Upvotes: 77

Gawin
Gawin

Reputation: 1004

I've run into a similar error under Mac OS X 10.10.

Details in the mkmf.log showed that this was due to:

Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.

Which was caused by the installation of a new version of Xcode. This was easily solved by accepting the Xcode license from Apple:

sudo xcodebuild -license

Hope this might help someone in the future ;-)

Upvotes: 8

Related Questions