わさっきhb

大学(教育研究)とか ,親馬鹿とか,和歌山とか,とか,とか.

Cygwinでrbenv install 2.0.0がエラー

Windows 8.1のPCに,Cygwinの64ビット版を入れ,一通りのことをしてから,

  • rbenv install 2.2.0

を実行すると,エラーが発生しました.
エラーメッセージは:

uncommon.mk:187: recipe for target 'build-ext' failed
make: *** [build-ext] Error 2

/tmp/ruby-build.年月日時分秒.たぶんプロセスID.log を読むと,以下のとおり,「utoa」の宣言で,衝突が起こったとのこと.

printf.c:23:1: エラー: ‘utoa’ と型が競合しています
 utoa(char *p, char *e, unsigned int x)
 ^
In file included from /usr/include/stdio.h:29:0,
                 from ../../.././include/ruby/defines.h:26,
                 from ../../.././include/ruby/ruby.h:29,
                 from ../../.././include/ruby.h:33,
                 from printf.c:1:
/usr/include/stdlib.h:184:8: 備考: 前の ‘utoa’ の宣言はここです
 char * _EXFUN(utoa,(unsigned, char *, int));
        ^
Makefile:241: recipe for target 'printf.o' failed
make[2]: *** [printf.o] Error 1

Emacsで /tmp/ruby-build.年月日時分秒.たぶんプロセスID/ruby-2.2.0/ext/-test-/printf/printf.c を開き,3箇所出現する「utoa」を,すべて「uutoa」に変更し,保存しました.テストコードのエラーなので,インストール後に影響しないはずです.
あとはシェルで

  • cd /tmp/ruby-build.年月日時分秒.たぶんプロセスID/ruby-2.2.0
  • make
  • make install

とすると,無事にインストールができ,

  • rbenv versions

を実行したら「2.2.0」が表示されました.