41

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 ***
Amod Pandey
  • 1,336
  • 3
  • 14
  • 22

14 Answers14

77

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
Zack Xu
  • 11,505
  • 9
  • 70
  • 78
  • 2
    I'm on El Capitian OSX 10.11.2. When I first did `gem install puma` - it gave me `ERROR: Failed to build gem native extension`. I then tried your send command (with puma version "2.9.1") and it seems to have worked with no errors! (yay!). Please would you be able to explain what this command mean? (I'm curious now as to why this command solves the problem). Thanks for your help!!! – Atlas7 Jan 20 '16 at 14:23
  • Worked for me on El Capitan, no idea why though. – JoannaFalkowska Mar 31 '16 at 10:07
  • install special version of puma that what i needed exactly – mmike May 10 '16 at 15:55
  • 5
    On El Capitan, run `gem install puma -v '2.11.2' -- --with-opt-dir=/usr/local/opt/openssl`. This works fine for me. – Kevin R. Jun 28 '16 at 14:27
  • 9
    `gem install puma -v '3.6.0' -- --with-opt-dir=/usr/local/opt/openssl` worked on seirra – mahi Mar 23 '17 at 16:08
  • I'm also on El Capitan and ran @KevinR. solution. worked for me too. Although I would like to know why in this specific OS that worked and how – nrmb Aug 10 '17 at 03:50
  • Thanks @mahi, I'm on El Captain and this worked like a charm. Cheers m8! – forkinspace May 25 '18 at 14:52
  • gem install puma -v '3.6.0' -- --with-opt-dir=/usr/local/opt/openssl worked for me on MacOSX 10.14.3 (18D109) – Nmuta May 17 '19 at 21:47
  • [This comment](https://github.com/puma/puma/issues/2304#issuecomment-664448309) on [this issue](https://github.com/puma/puma/issues/2304) helped me install 4.3.5 on Big Sur. `gem install puma -v '4.3.5' -- --with-cflags="-Wno-error=implicit-function-declaration"` – Navid Khan Jan 05 '21 at 06:41
41

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
Beartech
  • 6,173
  • 1
  • 18
  • 41
  • @Ameen what isn't working? Are you getting the same error as above or a different error? Also note this is for OS X 10.12.4 not Ubuntu. There is a good chance the openssl library is somewhere else in Ubuntu. – Beartech Sep 22 '18 at 00:15
  • 1
    Worked for OSX 10.12.6 (Sierra), `bundle install` is now successful. – xaunlopez Feb 18 '19 at 02:01
  • Omg this is what i needed. Worked on macOS 10.14.3 – Alex Mar 21 '19 at 17:59
22

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"
kometen
  • 6,536
  • 6
  • 41
  • 51
19

libssl1.0-dev installing helped to me. Try

apt-get install libssl1.0-dev

and then

gem install puma
Victor
  • 897
  • 8
  • 4
18

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
AkashP
  • 676
  • 6
  • 14
13

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
Konstantin Rudy
  • 2,237
  • 25
  • 22
  • This will may trigger a warning and will not work ```Warning: Refusing to link: openssl Linking keg-only openssl means you may end up linking against the insecure, deprecated system OpenSSL while using the headers from Homebrew's openssl. Instead, pass the full include/library paths to your compiler e.g.: -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib``` – hatenine Mar 15 '17 at 10:41
9

It could be an open ssl error

gem install puma -v 2.11.2 -- --with-opt-dir=/usr/local/opt/openssl
Bloomberg
  • 2,317
  • 2
  • 25
  • 47
8

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 ;-)

Gawin
  • 994
  • 10
  • 12
8

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

Community
  • 1
  • 1
morgler
  • 1,669
  • 1
  • 18
  • 26
5

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"
Marek Příhoda
  • 11,108
  • 3
  • 39
  • 53
Amod Pandey
  • 1,336
  • 3
  • 14
  • 22
4

I had to do this beforehand:

sudo apt-get install libgmp3-dev
Deepak Mahakale
  • 22,834
  • 10
  • 68
  • 88
matsko
  • 21,895
  • 21
  • 102
  • 144
  • I tried ```sudo apt-get install libssl-dev``` then installed ```gem install puma -v '3.1.0'``` but it didn't worked. Then I ```sudo apt-get install libgmp3-dev``` then installed gem it worked. Thanks @matsko – sagar junnarkar Mar 31 '16 at 09:24
3

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
Deepak Mahakale
  • 22,834
  • 10
  • 68
  • 88
1

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)

ykadaru
  • 1,108
  • 2
  • 16
  • 32
0

Install these packages.

apt-get install openssl ruby-openssl libssl-dev
Deepak Mahakale
  • 22,834
  • 10
  • 68
  • 88