puma gem - Failed to build gem native extension

2019-01-31 01:34发布

问题:

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 ***

回答1:

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


回答2:

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


回答3:

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


回答4:

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



回答5:

It could be an open ssl error

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


回答6:

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



回答7:

libssl1.0-dev installing helped to me. Try

apt-get install libssl1.0-dev

and then

gem install puma


回答8:

I had to do this beforehand: sudo apt-get install libgmp3-dev



回答9:

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


回答10:

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"


回答11:

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)



标签: puma