LoginSignup
7
3

More than 5 years have passed since last update.

Rails5のgem installでnio4rのインストールに失敗する

Last updated at Posted at 2016-10-31
  • macOS Sierra
  • Ruby 2.3

gem install rails --no-ri --no-rdoc したところ以下のエラーで詰まる

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

    current directory: /Users/{username}/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/nio4r-1.2.1/ext/nio4r
/Users/{username}/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20161031-36453-o4rcff.rb extconf.rb
checking for unistd.h... *** 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/{username}/.rbenv/versions/2.3.1/bin/$(RUBY_BASE_NAME)
/Users/{username}/.rbenv/versions/2.3.1/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
  from /Users/{username}/.rbenv/versions/2.3.1/lib/ruby/2.3.0/mkmf.rb:587:in `try_cpp'
  from /Users/{username}/.rbenv/versions/2.3.1/lib/ruby/2.3.0/mkmf.rb:1091:in `block in have_header'
  from /Users/{username}/.rbenv/versions/2.3.1/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
  from /Users/{username}/.rbenv/versions/2.3.1/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
  from /Users/{username}/.rbenv/versions/2.3.1/lib/ruby/2.3.0/mkmf.rb:320:in `open'
  from /Users/{username}/.rbenv/versions/2.3.1/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
  from /Users/{username}/.rbenv/versions/2.3.1/lib/ruby/2.3.0/mkmf.rb:320:in `open'
  from /Users/{username}/.rbenv/versions/2.3.1/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
  from /Users/{username}/.rbenv/versions/2.3.1/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
  from /Users/{username}/.rbenv/versions/2.3.1/lib/ruby/2.3.0/mkmf.rb:1090:in `have_header'
  from extconf.rb:3:in `<main>'

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

  /Users/{username}/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/nio4r-1.2.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/{username}/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/nio4r-1.2.1 for inspection.
Results logged to /Users/{username}/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/nio4r-1.2.1/gem_make.out

やったこと

xcodeコマンドラインツールのインストール

xcode-select --install 

gccのライセンスに同意

sudo gcc --version
↓
qで最下行表示後、"agree"を入力しEnter

再度実行

gem install rails --no-ri --no-rdoc

→無事インストールできた


参考: http://easyramble.com/failed-to-build-gem-native-extension.html

7
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3