1

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/openssl@1.1/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/openssl@1.1/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/openssl@1.1/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 */

Jason FB
  • 4,752
  • 3
  • 38
  • 69

3 Answers3

1

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

Community
  • 1
  • 1
Jason FB
  • 4,752
  • 3
  • 38
  • 69
  • I had this problem when updating puma. running the command helped. – Yshmarov Nov 03 '21 at 11:25
  • note that there was a distinct root cause (fixed with #3) that I think affected XCode 12--- the answer for that is here, but it is NOT a duplicate because this question was filed after XCode 12 https://stackoverflow.com/questions/63187613/fail-to-bundle-install-puma-4-3-5-or-gem-puma-with-ruby-2-6-6-on-macos-10-15-6 – Jason FB Apr 16 '22 at 13:33
0

I faced the same issue when i was trying to install gem for Jekyll.

xcode-select --install

This solved the issue.

0

I downloaded and installed "Command Line Tools for Xcode 13" from here https://developer.apple.com/download/all/ and it solved the issue for me. xcode-select --install said it was going to take over an hour.