122
122

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.

MavericksでC拡張を含むgemをインストールできない場合の対処法

Last updated at Posted at 2013-10-28

TL;DR

$ xcode-select --install
$ sudo xcodebuild -license

流れ

MavericksにOSをアップデートした後に boxen を実行したら gem install json -v '1.8.1' に失敗した。Boxenはシステムのrubyを使って実行しなければならず、MavericksからシステムのRubyが2.0.0p247に上がった影響で色々と環境構築から必要になるみたいだ。

分かりやすいように gem コマンドだけを実行するとこんなエラーがでる。

$ sudo gem install json -v '1.8.1'
Fetching: json-1.8.1.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing json:
	ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/json-1.8.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/json-1.8.1/ext/json/ext/generator/gem_make.out

何やらヘッダファイルが見つからないとのこと。Command Line Developer Toolsが必要らしいということが分かったのでインストール。

$ xcode-select --install

これで十分だと思っていたら次はMakefileの生成に失敗して、Xcodeのライセンスに同意しないといけないので次のコマンドを実行。

$ sudo xcodebuild -license

これで無事にjson gemをインストールできた。

$ sudo gem install json -v '1.8.1'
Building native extensions.  This could take a while...
Successfully installed json-1.8.1
1 gem installed
$ ./script/boxen  # 成功
122
122
2

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?