Quantcast
Channel: HAPPY*TRAP » Mac
Viewing all articles
Browse latest Browse all 14

Mac OS Xでgccが実行できない

$
0
0
OS_X_Mavericks
http://www.apple.com

mac os x上でknife-soloのgemインストールが失敗する原因が、Xcodeのライセンスに同意していなかったためgccが実行できない状態だった、という話。

以下のように、knife-soloをインストールするも、libyajl2というライブラリのビルドで失敗。

$ gem install --no-ri --no-rdoc knife-solo
(省略)
Fetching: libyajl2-1.0.1.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing knife-solo:
    ERROR: Failed to build gem native extension.

    /Users/machi/.rvm/rubies/ruby-2.1.1/bin/ruby extconf.rb
creating Makefile
/Users/machi/.rvm/gems/ruby-2.1.1/gems/libyajl2-1.0.1/ext/libyajl2
extconf.rb:104:in `makemakefiles': unhandled exception
    from extconf.rb:143:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/machi/.rvm/gems/ruby-2.1.1/gems/libyajl2-1.0.1 for inspection.
Results logged to /Users/machi/.rvm/gems/ruby-2.1.1/extensions/x86_64-darwin-13/2.1.0/libyajl2-1.0.1/gem_make.out

該当のコード(extconf.rb:104)を読んでみてもエラーになる原因がわからなかったのですが、Cのコンパイラにgccを指定している記述が近くにあったので、もしかしてgccがインストールされてないかも?と思い当たり、gccを実行してみると、インストールはされていましたが何やらメッセージが表示されて処理が進まない状況でした。。

$ gcc -v

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

$ sudo gcc -v
You have not agreed to the Xcode license agreements. You must agree to both license agreements below in order to use Xcode.

Hit the Enter key to view the license agreements at '/Applications/Xcode.app/Contents/Resources/English.lproj/License.rtf'

Xcodeのライセンスを確認して同意するように言われているので指示通りにEnterキーを押して、内容を表示。

最後まで読むと下記のように聞かれるので、問題なければ「agree」と入力。

By typing 'agree' you are agreeing to the terms of the software license agreements. Type 'print' to print them or anything else to cancel, [agree, print, cancel]

再度、gem installを実行したら無事インストールできました。

$ gem install --no-ri --no-rdoc knife-solo
Building native extensions.  This could take a while...
Successfully installed libyajl2-1.0.1
Fetching: ffi-1.9.3.gem (100%)
Building native extensions.  This could take a while...
Successfully installed ffi-1.9.3
Fetching: ffi-yajl-1.1.0.gem (100%)
Building native extensions.  This could take a while...
Successfully installed ffi-yajl-1.1.0
Fetching: wmi-lite-1.0.0.gem (100%)
Successfully installed wmi-lite-1.0.0
Fetching: ipaddress-0.8.0.gem (100%)
Successfully installed ipaddress-0.8.0
Fetching: net-dhcp-1.2.1.gem (100%)
Successfully installed net-dhcp-1.2.1
Fetching: mixlib-shellout-2.0.0.rc.0.gem (100%)
Successfully installed mixlib-shellout-2.0.0.rc.0
Fetching: mixlib-config-2.1.0.gem (100%)
Successfully installed mixlib-config-2.1.0
Fetching: mixlib-cli-1.5.0.gem (100%)
Successfully installed mixlib-cli-1.5.0
Fetching: systemu-2.6.4.gem (100%)
Successfully installed systemu-2.6.4
Fetching: ohai-7.6.0.rc.0.gem (100%)
Successfully installed ohai-7.6.0.rc.0
Fetching: mixlib-authentication-1.3.0.gem (100%)
Successfully installed mixlib-authentication-1.3.0
Fetching: chef-12.0.0.alpha.2.gem (100%)
Successfully installed chef-12.0.0.alpha.2
Fetching: knife-solo-0.4.2.gem (100%)
Thanks for installing knife-solo!

If you run into any issues please let us know at:
  https://github.com/matschaffer/knife-solo/issues

If you are upgrading knife-solo please uninstall any old versions by
running `gem clean knife-solo` to avoid any errors.

See http://bit.ly/CHEF-3255 for more information on the knife bug
that causes this.
Successfully installed knife-solo-0.4.2
14 gems installed

Mac OS X10.9.4
Xcode6.0.1
gcc6.0

Viewing all articles
Browse latest Browse all 14

Trending Articles