LoginSignup
28
26

More than 5 years have passed since last update.

Mac で ruby-1.9.3-p385 がビルドできない問題を素早く解決する

Last updated at Posted at 2013-02-12

Mountain Lion あたりだと ruby-1.9.3-p385 のビルド時に以下のようなエラーが出る:

BUILD FAILED
(略)
Last 10 log lines:
compiling regenc.c
compiling regerror.c
compiling regexec.c
compiling regparse.c
regparse.c:582:15: error: implicit conversion loses integer precision: 'st_index_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
    return t->num_entries;
    ~~~~~~ ~~~^~~~~~~~~~~
1 error generated.
make: *** [regparse.o] Error 1

整数の精度を落とすような暗黙的型変換の警告(-Wshorten-64-to-32)と、警告をエラーにするオプション(-Werror)によってビルドが失敗している。

これを解決するには brew install apple-gcc42 して CC=/usr/local/bin/gcc-4.2 すればいいという情報が色々見つかるが、そんなことをしなくても警告を無視するだけでビルドは通る:

export CFLAGS=-Wno-error=shorten-64-to-32
# プリインストールの readline と OpenSSL は壊れているため、別途 Homebrew などでインストールしたものを使う
export CONFIGURE_OPTS="--with-openssl-dir=/path/to/dir --with-readline-dir=/path/to/dir"

rvm install ruby-1.9.3-p385
# or
rbenv install 1.9.3-p385

apple-gcc42 を使えば出ないはずの警告を無視することについて不安があるかもしれないが、 apple-gcc42 は警告のチェックが甘いだけである。

補足:homebrew で入れた openssl を使って Ruby をコンパイルすると SSL 利用時に証明書エラーが発生する場合の対応

28
26
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
28
26