matthew as a q.

競技プログラミングメイン

MBPの初期設定 part3 Rubyの開発環境ほか

  • rbenvでRubyのバージョン切り替え簡単にできるようにする

Homebrew + rbenv で Ruby をインストールする | deadwood

  • rbenvでインストール時にエラー

rbenvを使用しており、Rubyの普段使っているバージョンが2.0系でない方へ
Ruby on Rails チュートリアル:実例を使って Rails を学ぼう
上記の記事通り以下のコマンドで、インストールを行った時にエラーが出た。

rbenv install 2.0.0-p353 

エラーメッセージ

Downloading yaml-0.1.5.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/24f6093c1e840ca5df2eb09291a1dbf1
Installing yaml-0.1.5...
Installed yaml-0.1.5 to /Users/MYUSERNAME/.rbenv/versions/2.0.0-p353

Downloading ruby-2.0.0-p353.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/78282433fb697dd3613613ff55d734c1
Installing ruby-2.0.0-p353...

BUILD FAILED

Inspect or clean up the working tree at /var/folders/1z/cz314fjn6jd2z88swdjb7xqm0000gn/T/ruby-build.20140326030923.1817
Results logged to /var/folders/1z/cz314fjn6jd2z88swdjb7xqm0000gn/T/ruby-build.20140326030923.1817.log

Last 10 log lines:
In file included from ./include/ruby/ruby.h:1568:
In file included from ./include/ruby/intern.h:43:
./include/ruby/st.h:67:45: error: 'st_check_for_sizeof_st_index_t' declared as an array with a negative size
typedef char st_check_for_sizeof_st_index_t[SIZEOF_VOIDP == (int)sizeof(st_index_t) ? 1 : -1];
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ext/include/x86_64-darwin13.1.0/ruby/config.h:54:22: note: expanded from macro 'SIZEOF_VOIDP'
#define SIZEOF_VOIDP 8
                     ^
4 warnings and 3 errors generated.
make: *** [dmyencoding.o] Error 1

logでてたので、ログを見る。

less /var/folders/1z/cz314fjn6jd2z88swdjb7xqm0000gn/T/ruby-build.20140326030923.1817.log

よくわからん。

homebrewでrbenvをインストールしていたので、homebrew関係でエラー出てないか、

brew doctor

で、エラーないかチェックした。

エラーメッセージとは関係ないけど、sudoなんちゃら、という文字が見えたので、sudoでインストールすればいいのでは、と思いたち、

sudo rbenv install 2.0.0-p353

インストールできた。
(本当はむやみにsudo使うべきではないし、もっときちんとした解決策ありそう。)