1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.が解決できない。

Posted at

bundle install をするとエラーがでる。

ターミナルの内容はこちら

Fetching msgpack 1.2.9
Installing msgpack 1.2.9 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/tech-camp/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/msgpack-1.2.9/ext/msgpack
/Users/tech-camp/.rbenv/versions/2.5.1/bin/ruby -r ./siteconf20190318-3361-1d5xqm2.rb extconf.rb
checking for ruby/st.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/tech-camp/.rbenv/versions/2.5.1/bin/$(RUBY_BASE_NAME)
/Users/tech-camp/.rbenv/versions/2.5.1/lib/ruby/2.5.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/tech-camp/.rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb:590:in `try_cpp'
	from /Users/tech-camp/.rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb:1097:in `block in have_header'
	from /Users/tech-camp/.rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb:947:in `block in checking_for'
	from /Users/tech-camp/.rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb:350:in `block (2 levels) in postpone'
	from /Users/tech-camp/.rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb:320:in `open'
	from /Users/tech-camp/.rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb:350:in `block in postpone'
	from /Users/tech-camp/.rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb:320:in `open'
	from /Users/tech-camp/.rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb:346:in `postpone'
	from /Users/tech-camp/.rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb:946:in `checking_for'
	from /Users/tech-camp/.rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb:1096: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/tech-camp/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-15/2.5.0-static/msgpack-1.2.9/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/tech-camp/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/msgpack-1.2.9 for inspection.
Results logged to /Users/tech-camp/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-15/2.5.0-static/msgpack-1.2.9/gem_make.out

An error occurred while installing msgpack (1.2.9), and Bundler cannot continue.
Make sure that `gem install msgpack -v '1.2.9' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  bootsnap was resolved to 1.4.1, which depends on
    msgpack

解決方法

エラーの起こっているディテクトリで以下のコマンドを実行

xcode-select --install

これを実行するとインストール画面がでるので、インストールし再度,bundle installすると無事インストール完了

疑問点

  • xcodeって?
  • msgpackではなく、bootsnapが原因だった?
  • そもそも上記2つってなに?
1
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
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?