watchbuild icon indicating copy to clipboard operation
watchbuild copied to clipboard

Error on macOS Mojave while installing

Open telmen opened this issue 7 years ago • 5 comments

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

current directory: /usr/local/lib/ruby/gems/2.6.0/gems/unf_ext-0.0.7.5/ext/unf_ext

/usr/local/opt/ruby/bin/ruby -I /usr/local/Cellar/ruby/2.6.0/lib/ruby/2.6.0 -r ./siteconf20190305-71068-fwf5h8.rb extconf.rb checking for -lstdc++... *** 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=/usr/local/Cellar/ruby/2.6.0/bin/$(RUBY_BASE_NAME) --with-static-libstdc++ --without-static-libstdc++ --with-stdc++lib --without-stdc++lib /usr/local/Cellar/ruby/2.6.0/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 /usr/local/Cellar/ruby/2.6.0/lib/ruby/2.6.0/mkmf.rb:552:in try_link0' from /usr/local/Cellar/ruby/2.6.0/lib/ruby/2.6.0/mkmf.rb:570:in try_link' from /usr/local/Cellar/ruby/2.6.0/lib/ruby/2.6.0/mkmf.rb:789:in try_func' from /usr/local/Cellar/ruby/2.6.0/lib/ruby/2.6.0/mkmf.rb:1016:in block in have_library' from /usr/local/Cellar/ruby/2.6.0/lib/ruby/2.6.0/mkmf.rb:959:in block in checking_for' from /usr/local/Cellar/ruby/2.6.0/lib/ruby/2.6.0/mkmf.rb:361:in block (2 levels) in postpone' from /usr/local/Cellar/ruby/2.6.0/lib/ruby/2.6.0/mkmf.rb:331:in open' from /usr/local/Cellar/ruby/2.6.0/lib/ruby/2.6.0/mkmf.rb:361:in block in postpone' from /usr/local/Cellar/ruby/2.6.0/lib/ruby/2.6.0/mkmf.rb:331:in open' from /usr/local/Cellar/ruby/2.6.0/lib/ruby/2.6.0/mkmf.rb:357:in postpone' from /usr/local/Cellar/ruby/2.6.0/lib/ruby/2.6.0/mkmf.rb:958:in checking_for' from /usr/local/Cellar/ruby/2.6.0/lib/ruby/2.6.0/mkmf.rb:1011:in have_library' from extconf.rb:6:in

'

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

/usr/local/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0/unf_ext-0.0.7.5/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/lib/ruby/gems/2.6.0/gems/unf_ext-0.0.7.5 for inspection. Results logged to /usr/local/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0/unf_ext-0.0.7.5/gem_make.out

telmen avatar Mar 05 '19 06:03 telmen

same here

Xgamefactory avatar Oct 06 '19 01:10 Xgamefactory

I had the same issue.

What did the trick for me was following this Stack Overflow answer that I quote here:

For macOS 10.14 Mojave, make sure you have already installed command line tools via xcode-select --install and the run the following command to install std headers.

sudo open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

Now try your command again.

Then I had other issues with Ruby but that's for another day 😆

zntfdr avatar Oct 22 '19 07:10 zntfdr

I was running into a problem installing a gem dependency of fastlane on macOS 10.15.3 (Catalina), and google led me to this issue.

@zntfdr solution doesn't work on Catalina.

After a bit of googling I found this, which worked to fix my problem:

$ export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
$ gem install unf_ext -v '0.0.7.5'

I think this may also be relevant to this issue?

Hope this helps.

Krishna avatar May 01 '20 01:05 Krishna

macOS Big Sur

Version 11.2.1

Delete & reinstall Xcode command line developer tools

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

vaibhavhrt avatar Feb 11 '21 17:02 vaibhavhrt

macOS Big Sur

Version 11.2.1

Delete & reinstall Xcode command line developer tools

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

Great tip, which also works for version 12.0.1

leafOfTree avatar Dec 01 '21 09:12 leafOfTree