@peccul is peccu

(love peccu '(emacs lisp cat outdoor bicycle mac linux coffee))

= OSX Mountain LionでRVM使ってRuby2.0をインストール

[2013-02-26 00:18:38]

いまだに homebrew じゃなくて Mac Ports にしがみついてます.

Rubyが20周年で,Ruby 2.0が出たらしくとりあえずインストールだけでもしてみるか,というところです.
rvmでインストールしてみたらエラー(後半に載せました)で止まったので,opensslはMac Portsでインストールしたものを使うことにしました.
下のコマンドで指定するとなぜかreadlineのエラーも発生せずにインストール完了しました.(参考リンクCan't install gems in ruby-head / 2.0.0-preview1 when using https://rubygems.org source · Issue #1290 · wayneeseguin/rvm · GitHub)

% rvm install 2.0.0 --skip-openssl --with-opt-dir="/opt/local/"

with-opt-dir="/opt/local/"の部分は,MacPortsのプレフィックスで,homebrew使ってる人は --with-opt-dir="`brew --prefix openssl`"でいいらしいです.
ちなみに1.9.3でも同様にインストール失敗してあきらめてたけど,同じ解決策でインストールできた.

あと,zsh使ってるとrvm use systemがうまく動作していないように見えるんだけど,Issue #1500このバグが残ってるんじゃないだろうか...

エラーログとか

  • rvm install 2.0.0の出力
% rvm install 2.0.0
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.8/x86_64/ruby-2.0.0-p0.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
Fetching yaml-0.1.4.tar.gz to /Users/peccu/.rvm/archives
Extracting yaml to /Users/peccu/.rvm/src/yaml-0.1.4
Prepare yaml in /Users/peccu/.rvm/src/yaml-0.1.4.
Configuring yaml in /Users/peccu/.rvm/src/yaml-0.1.4.
Compiling yaml in /Users/peccu/.rvm/src/yaml-0.1.4.
Installing yaml to /Users/peccu/.rvm/usr

Please note that it's required to reinstall all rubies:

    rvm reinstall all --force

Fetching openssl-1.0.1c.tar.gz to /Users/peccu/.rvm/archives
Extracting openssl to /Users/peccu/.rvm/src/openssl-1.0.1c
Configuring openssl in /Users/peccu/.rvm/src/openssl-1.0.1c.
Error running './Configure darwin64-x86_64-cc -I/Users/peccu/.rvm/usr/include -L/Users/peccu/.rvm/usr/lib zlib no-asm no-krb5 --prefix=/Users/peccu/.rvm/usr no-shared ', please read /Users/peccu/.rvm/log/ruby-2.0.0-p0/openssl/configure.log
Compiling openssl in /Users/peccu/.rvm/src/openssl-1.0.1c.
Error running 'make', please read /Users/peccu/.rvm/log/ruby-2.0.0-p0/openssl/make.log

Please note that it's required to reinstall all rubies:

    rvm reinstall all --force

Updating openssl certificates
Error running 'update_openssl_certs', please read /Users/peccu/.rvm/log/ruby-2.0.0-p0/openssl.certs.log
Installing Ruby from source to: /Users/peccu/.rvm/rubies/ruby-2.0.0-p0, this may take a while depending on your cpu(s)...
ruby-2.0.0-p0 - #downloading ruby-2.0.0-p0, this may take a while depending on your connection...
ruby-2.0.0-p0 - #extracted to /Users/peccu/.rvm/src/ruby-2.0.0-p0 (already extracted)
ruby-2.0.0-p0 - #configuring
ruby-2.0.0-p0 - #compiling
Error running 'make', please read /Users/peccu/.rvm/log/ruby-2.0.0-p0/make.log
There has been an error while running make. Halting the installation.
  • opensslのconfigureログ
% cat /Users/peccu/.rvm/log/ruby-2.0.0-p0/openssl/configure.log
[2013-02-26 00:33:20] ./Configure
target already defined - darwin64-x86_64-cc (offending arg: )
  • opensslのmakeログ(一部)
[2013-02-26 00:33:20] make
...
...
making all in crypto/des...
cc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -O   -c -o set_key.o set_key.c
set_key.c:399:17: error: unsupported inline asm: input with type 'unsigned long' matching output with type 'unsigned int'
                *(k++)=ROTATE(t2,30)&0xffffffffL;
                       ~~~~~~~^~~~~~
./des_locl.h:170:19: note: expanded from macro 'ROTATE'
                                        : "I"(n),"0"(a) \
                                                     ^
set_key.c:402:17: error: unsupported inline asm: input with type 'unsigned long' matching output with type 'unsigned int'
                *(k++)=ROTATE(t2,26)&0xffffffffL;
                       ~~~~~~~^~~~~~
./des_locl.h:170:19: note: expanded from macro 'ROTATE'
                                        : "I"(n),"0"(a) \
                                                     ^
2 errors generated.
make[2]: *** [set_key.o] Error 1
make[1]: *** [subdirs] Error 1
make: *** [build_crypto] Error 1
  • update_openssl_certsのログ

これはopensslのビルドに失敗してるから当たり前っぽい

% cat /Users/peccu/.rvm/log/ruby-2.0.0-p0/openssl.certs.log
[2013-02-26 00:33:27] update_openssl_certs
__rvm_cd:cd:6: no such file or directory: /Users/peccu/.rvm/usr/ssl
% tail /Users/peccu/.rvm/log/ruby-2.0.0-p0/make.log
linking shared-object racc/cparse.bundle
installing default cparse libraries
compiling readline.c
readline.c: In function 'username_completion_proc_call':
readline.c:1688: error: 'username_completion_function' undeclared (first use in this function)
readline.c:1688: error: (Each undeclared identifier is reported only once
readline.c:1688: error: for each function it appears in.)
make[2]: *** [readline.o] Error 1
make[1]: *** [ext/readline/all] Error 2
make: *** [build-ext] Error 2