1
1

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.

[Rails]Xcodeの自動バージョンアップに注意(ERROR: Failed to build gem native extension.)

Posted at

環境

macOS 10.14.5
ruby 2.6.3(rbenv)
rails 6.0.0
Xcode 11.1

bundle install でエラー発生

久しぶりに Railsアプリ(6.0.0)を作成しようとしてハマりました。nokogiri gemがインストールできなくなっており、進めなくなっていたのです。

Installing nokogiri 1.10.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
...
To see why this extension failed to compile, please check the mkmf.log which can
be found here:

/Users/mac_user/environment/api_test/vendor/bundle/ruby/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/nokogiri-1.10.4/mkmf.log

extconf failed, exit code 1

原因は Xcodeにあり

色々調べて時間がかかってしまったのですが、エラーメッセージに書いてある通りに、mkmf.log を確認すれば解決しました。Xcodeのライセンスに「Agree」せよと書かれています。

mkmf.log
/Users/nspenchan/.rbenv/versions/2.6.3/lib/ruby/2.6.0/mkmf.rb:406: warning: Insecure world writable dir /Users/nspenchan in PATH, mode 040777


Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.


checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

解決 Xcodeでライセンスに同意する

Xcodeを立ち上げて、ライセンス確認画面で「Agree」します。必要なコンポーネントが自動でインストールされて、問題が解決しました。

知らない間に Xcodeがアップデートされていたのです。そういえば、前もこんなことがあったような... すっかり忘れていましたわ。
エラーメッセージを見るのは苦手ですぐに日本語情報をググってしまいます。今回はそれで時間を無駄にしてしまいました。まずは「親切なエラーメッセージさん」を確認することを習慣にしたいと思います。

たったこれだけのことですが、自分のような初心者はハマると思いますので、情報共有します。

1
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?