Search code examples
rubybundlerpumamacos-big-sur

gem install puma -v '4.3.7' fails on Mac OS Big Sur Ruby 2.6.3 Bundler version 2.2.19


symptom: gem install puma -v '4.3.7' crashes

Mac OS Big Sur 11.4

• Ruby 2.6.3

Bundler version 2.2.19

Homebrew 3.1.9

jason@ % gem install puma -v '4.3.7' --source 'https://rubygems.org/'
Building native extensions. This could take a while...
ERROR:  Error installing puma:
    ERROR: Failed to build gem native extension.

    current directory: /Users/jason/.rvm/gems/ruby-2.6.3/gems/puma-4.3.7/ext/puma_http11
/Users/jason/.rvm/rubies/ruby-2.6.3/bin/ruby -I /Users/jason/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0 -r ./siteconf20210611-75981-19nb5m9.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
    --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/jason/.rvm/rubies/ruby-2.6.3/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
    --without-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/jason/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/jason/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/mkmf.rb:552:in `try_link0'
    from /Users/jason/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/mkmf.rb:570:in `try_link'
    from /Users/jason/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/mkmf.rb:782:in `try_func'
    from /Users/jason/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/mkmf.rb:1016:in `block in have_library'
    from /Users/jason/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/mkmf.rb:959:in `block in checking_for'
    from /Users/jason/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/mkmf.rb:361:in `block (2 levels) in postpone'
    from /Users/jason/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/mkmf.rb:331:in `open'
    from /Users/jason/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/mkmf.rb:361:in `block in postpone'
    from /Users/jason/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/mkmf.rb:331:in `open'
    from /Users/jason/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/mkmf.rb:357:in `postpone'
    from /Users/jason/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/mkmf.rb:958:in `checking_for'
    from /Users/jason/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/mkmf.rb:1011:in `have_library'
    from extconf.rb:13:in `block in <main>'
    from extconf.rb:13:in `each'
    from extconf.rb:13:in `find'
    from extconf.rb:13:in `<main>'

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

  /Users/jason/.rvm/gems/ruby-2.6.3/extensions/-darwin-20/2.6.0/puma-4.3.7/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/jason/.rvm/gems/ruby-2.6.3/gems/puma-4.3.7 for inspection.
Results logged to /Users/jason/.rvm/gems/ruby-2.6.3/extensions/-darwin-20/2.6.0/puma-4.3.7/gem_make.out
jason@ % 

here is the mfmk.log

jason@ % more /Users/jason/.rvm/gems/ruby-2.6.3/extensions/-darwin-20/2.6.0/puma-4.3.7/mkmf.log
"gcc -o conftest -I/Users/jason/.rvm/rubies/ruby-2.6.3/include/ruby-2.6.0/-darwin20 -I/Users/jason/.rvm/rubies/ruby-2.6.3/include/ruby-2.6.0/ruby/backward -I/Users/jason/.rvm/rubies/ruby-2.6.3/include/ruby-2.6.0 -I.  -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/libksba/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/[email protected]/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wno-error=implicit-function-declaration  -fno-common -pipe conftest.c  -L. -L/Users/jason/.rvm/rubies/ruby-2.6.3/lib -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/[email protected]/lib -L. -fstack-protector-strong -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/[email protected]/lib     -lruby.2.6   "
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */


Solution

  • This happens when you fail to install GCC or xcode-select.

    1. Be sure you have xcode-select installed
    xcode-select --install
    
    1. Be sure your version of puma installs
    gem install puma -v 'x.y.z'
    
    1. If neither of these work try
    bundle config build.puma --with-cflags="-Wno-error=implicit-function-declaration"
    

    and then re-run bundle install