1

I am trying to install puma onto my MacOS 10.13.6. To install puma, I run the command gem install puma but it returned

Building native extensions. This could take a while...
    ERROR:  Error installing puma:
        ERROR: Failed to build gem native extension.

   current directory: /Users/salem/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.12.0/ext/puma_http11
    /Users/salem/.rbenv/versions/2.5.1/bin/ruby -r ./siteconf20180801-14654-17z0n88.rb extconf.rb
    checking for BIO_read() in -lcrypto... *** extconf.rb failed ***
    Could not create Makefile due to some reason, probably lack of necessary
    libraries and/or headers.  Check the mkmf.log file for more details.  You may
    need configuration options.

    Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/Users/salem/.rbenv/versions/2.5.1/bin/$(RUBY_BASE_NAME)
        --with-puma_http11-dir
        --without-puma_http11-dir
        --with-puma_http11-include
        --without-puma_http11-include=${puma_http11-dir}/include
        --with-puma_http11-lib
        --without-puma_http11-lib=${puma_http11-dir}/lib
        --with-openssl-dir
        --with-openssl-include
        --without-openssl-include=${openssl-dir}/include
        --with-openssl-lib
        --without-openssl-lib=${openssl-dir}/lib
        --with-cryptolib
        --without-cryptolib
    /Users/salem/.rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
    You have to install development tools first.
        from 


    ...
    ...
    To see why this extension failed to compile, please check the mkmf.log which can be found here:

      /Users/salem/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/puma-3.12.0/mkmf.log

    extconf failed, exit code 1

Gem files will remain installed in /Users/salem/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puma-3.12.0 for inspection.
Results logged to /Users/salem/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/puma-3.12.0/gem_make.out`

The _mkmf.log_ can be found below...

clang -o conftest -I/Users/salem/.rbenv/versions/2.5.1/include/ruby-2.5.0/x86_64-darwin17 -I/Users/salem/.rbenv/versions/2.5.1/include/ruby-2.5.0/ruby/backward -I/Users/salem/.rbenv/versions/2.5.1/include/ruby-2.5.0 -I. -I/usr/local/opt/openssl/include -I/Users/salem/.rbenv/versions/2.5.1/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -Wno-error=shorten-64-to-32  -pipe conftest.c  -L. -L/Users/salem/.rbenv/versions/2.5.1/lib -L/usr/local/opt/openssl/lib -L. -L/Users/salem/.rbenv/versions/2.5.1/lib  -fstack-protector -L/usr/local/lib     -lruby.2.5.1-static -framework Foundation  -lpthread -ldl -lobjc "
error: unable to open output file '~/tmp/conftest-8ad96a.o': 'No such file or directory'
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

Xcode is installed on my Mac. I ran xcode-select --install which confirmed that Xcode was already installed.

I then thought it could be a permissions issue...

~ $ ls -lah tmp
total 0
drwxrwxrwx   3 salem  staff    96B Jul 30 08:35 .
drwxr-xr-x+ 62 salem  staff   1.9K Aug  1 13:17 ..
drwxr-xr-x   3 salem  staff    96B Jul 27 15:11 vmSWVyg

but it appears that it has the correct permissions set.

This issue also arises when installing nokugiri

Sal
  • 19
  • 1
  • 5
  • Same issue with `gem install ffi`. – Cœur Oct 20 '18 at 10:40
  • Related: [How to fix a bundle “nio4r error” on Rails 5.1.6 on mac10.13](https://stackoverflow.com/questions/50576514/how-to-fix-a-bundle-nio4r-error-on-rails-5-1-6-on-mac10-13) – Cœur Oct 20 '18 at 11:59
  • Related: [ruby:2.5.1-slim or ruby-2.5.1-alpine fails on nokogiri gem](https://stackoverflow.com/questions/52050526/ruby2-5-1-slim-or-ruby-2-5-1-alpine-fails-on-nokogiri-gem) – Cœur Oct 20 '18 at 12:00
  • Related: [Can't Find ffi.h When Installing ffi ruby gem](https://stackoverflow.com/questions/47230735/cant-find-ffi-h-when-installing-ffi-ruby-gem) – Cœur Oct 20 '18 at 12:04
  • Please post the output of `gem env` – lacostenycoder Oct 20 '18 at 16:17
  • Personally, I solved it with `xcode-select --install` after making sure that `xcode-select -p` was pointing to a stable version of Xcode 10. – Cœur Oct 20 '18 at 20:24
  • I recommend removing rbenv and all its installed Rubies, then reinstalling rbenv and Ruby (or better, rvm and Ruby) from scratch and retrying the operation. If it still isn't working, ensure that you have [a modern version of OpenSSL installed](https://stackoverflow.com/a/17231736/3784008). [Same issue reported here](https://stackoverflow.com/q/51692408/3784008). – anothermh Oct 21 '18 at 06:23

1 Answers1

2

You might want to install openssl, e.g. via homebrew:

brew install openssl

A similar issue was also discussed on github.

In case of nokogiri, libxml might be missing:

brew install libxml2
skahlert
  • 627
  • 4
  • 8
  • Ah, sorry, I thought you would automatically get the bounty, then I just discovered that [Bounties only default to +2 answers](https://meta.stackoverflow.com/questions/266290/why-bounty-was-not-awarded) – Cœur Oct 28 '18 at 12:06