There's an echo in my head

日々のメモ。

ruby-2.0.0-rc2を入れた(いったん)

環境はOS X 10.8.2 Mountain Lion。

とりあえずrc1と同じ手順

$ cd ~/.rbenv/plugins/ruby-build
$ git pull origin master
$ CONFIGURE_OPTS="--enable-shared --with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline`" rbenv install 2.0.0-rc2

Downloading openssl-1.0.1e.tar.gz...
-> https://www.openssl.org/source/openssl-1.0.1e.tar.gz
Installing openssl-1.0.1e...

BUILD FAILED

Inspect or clean up the working tree at /var/folders/6w/dd2sdf8900371rcp2y2z5md00000gn/T/ruby-build.20130213020113.91684
Results logged to /var/folders/6w/dd2sdf8900371rcp2y2z5md00000gn/T/ruby-build.20130213020113.91684.log

Last 10 log lines:
x openssl-1.0.1e/VMS/TODO
x openssl-1.0.1e/VMS/ucx_shr_decc_log.opt
x openssl-1.0.1e/VMS/ucx_shr_decc.opt
x openssl-1.0.1e/VMS/ucx_shr_vaxc.opt
x openssl-1.0.1e/VMS/VMSify-conf.pl
x openssl-1.0.1e/VMS/WISHLIST.TXT
/var/folders/6w/dd2sdf8900371rcp2y2z5md00000gn/T/ruby-build.20130213020113.91684/openssl-1.0.1e /var/folders/6w/dd2sdf8900371rcp2y2z5md00000gn/T/ruby-build.20130213020113.91684 ~/.rbenv/plugins/ruby-build
Operating system: i686-apple-darwinDarwin Kernel Version 12.2.1: Thu Oct 18 16:32:48 PDT 2012; root:xnu-2050.20.9~2/RELEASE_X86_64
Configuring for darwin64-x86_64-cc
Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [experimental-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-dso] [no-krb5] [sctp] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--test-sanity] os/compiler[:flags]

失敗Mac OS Xでrbenv install 2.0.0-rc2に失敗する問題の調査ログを読んでみると、opensslのconfigureオプションから--with-openssl-dirがなくなって--openssldirになったのが原因の模様。

opensslはHomebrewでインストール済みなので、RUBY_CONFIGURE_OPTS--with-openssl-dirを指定するとopensslのビルドがスキップされる*1のを使って再度チャレンジ。

$ CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline`" RUBY_CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl`" rbenv install 2.0.0-rc2

Downloading ruby-2.0.0-rc2.tar.gz...
-> http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-rc2.tar.gz
Installing ruby-2.0.0-rc2...
Installed ruby-2.0.0-rc2 to /Users/aerial/.rbenv/versions/2.0.0-rc2

通った。試しにOpenSSLを使ってhttps://www.google.comの内容を落としてみる。

require "openssl"
require 'net/https'
https = Net::HTTP.new('www.google.com', 443)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
https.verify_depth = 5
https.start { |w|
  response = w.get('/')
  puts response.body
}
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
    from /Users/aerial/.rbenv/versions/2.0.0-rc2/lib/ruby/2.0.0/net/http.rb:917:in `connect'
  from /Users/aerial/.rbenv/versions/2.0.0-rc2/lib/ruby/2.0.0/net/http.rb:917:in `block in connect'
  from /Users/aerial/.rbenv/versions/2.0.0-rc2/lib/ruby/2.0.0/timeout.rb:51:in `timeout'
    from /Users/aerial/.rbenv/versions/2.0.0-rc2/lib/ruby/2.0.0/net/http.rb:917:in `connect'
  from /Users/aerial/.rbenv/versions/2.0.0-rc2/lib/ruby/2.0.0/net/http.rb:861:in `do_start'
  from /Users/aerial/.rbenv/versions/2.0.0-rc2/lib/ruby/2.0.0/net/http.rb:850:in `start'
    from (irb):11
    from /Users/aerial/.rbenv/versions/2.0.0-rc2/bin/irb:12:in `<main>'

(´・ω・`)

ls `ruby -ropenssl -e "puts OpenSSL::X509::DEFAULT_CERT_FILE"`
ls: /usr/local/etc/openssl/cert.pem: No such file or directory

どうやらデフォルトの証明書がないのが原因らしい。でもそれ以外は動くので、とりあえずここまで。

*1:OSXにプリインストールされてるOpenSSLだとSEGVするのでそれ以外のものが指定されてればそっちを優先、って意味かなぁ(あやふや)

このブログに出てくるコードスニペッツは、引用あるいは断りがない限りMITライセンスです。