LoginSignup
2
0

More than 5 years have passed since last update.

MacでRails5のbundle install時にnio4rのエラーが出る

Posted at
  • macOS Sierra
  • Ruby 2.4.1

Rails5をインストールしようとしたら、nio4rのとこでエラーが出る。

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
    current directory: /Users/ryo/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/nio4r-2.1.0/ext/nio4r
/Users/ryo/.rbenv/versions/2.4.1/bin/ruby -r ./siteconf20171009-1873-ylw7vp.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/ryo/.rbenv/versions/2.4.1/bin/$(RUBY_BASE_NAME)
/Users/ryo/.rbenv/versions/2.4.1/lib/ruby/2.4.0/mkmf.rb:457:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/ryo/.rbenv/versions/2.4.1/lib/ruby/2.4.0/mkmf.rb:588:in `try_cpp'
    from /Users/ryo/.rbenv/versions/2.4.1/lib/ruby/2.4.0/mkmf.rb:1095:in `block in have_header'
    from /Users/ryo/.rbenv/versions/2.4.1/lib/ruby/2.4.0/mkmf.rb:945:in `block in checking_for'
    from /Users/ryo/.rbenv/versions/2.4.1/lib/ruby/2.4.0/mkmf.rb:351:in `block (2 levels) in postpone'
    from /Users/ryo/.rbenv/versions/2.4.1/lib/ruby/2.4.0/mkmf.rb:321:in `open'
    from /Users/ryo/.rbenv/versions/2.4.1/lib/ruby/2.4.0/mkmf.rb:351:in `block in postpone'
    from /Users/ryo/.rbenv/versions/2.4.1/lib/ruby/2.4.0/mkmf.rb:321:in `open'
    from /Users/ryo/.rbenv/versions/2.4.1/lib/ruby/2.4.0/mkmf.rb:347:in `postpone'
    from /Users/ryo/.rbenv/versions/2.4.1/lib/ruby/2.4.0/mkmf.rb:944:in `checking_for'
    from /Users/ryo/.rbenv/versions/2.4.1/lib/ruby/2.4.0/mkmf.rb:1094:in `have_header'
    from extconf.rb:5:in `<main>'

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

  /Users/ryo/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/nio4r-2.1.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/ryo/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/nio4r-2.1.0 for inspection.
Results logged to /Users/ryo/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/nio4r-2.1.0/gem_make.out

An error occurred while installing nio4r (2.1.0), and Bundler cannot continue.
Make sure that `gem install nio4r -v '2.1.0'` succeeds before bundling.

In Gemfile:
  rails was resolved to 5.1.4, which depends on
    actioncable was resolved to 5.1.4, which depends on
      nio4r

書いてある通り、 mkmf.log の中身を見てみたら以下の1行が書いてある。

Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.

Xcode9.0にバージョンアップした為か、ライセンスに同意してない状態だった為にエラーになっていたようでした。
Xcodeを起動して、ライセンス画面でagreeを選択したらエラー解消されました。

2
0
1

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
2
0