Ruby 2.0.0-p0インストール(Mac OS X 10.8.2)

More than 5 years have passed since last update.


0. 環境クリーンアップ

brew uninstall openssl

brew uninstall curl-ca-bundle
brew uninstall readline


1. brewアップデート

brew update


2. ruby-buildアップグレード

brew upgrade ruby-build


3. インストール可能リスト表示確認

rbenv install -l

----------
2.0.0-p0
----------


4. Rubyインストール

参考: Install Ruby 2.0.0-p0 /w OS X (Using Rbenv and Homebrew) #Ruby - Qiita


OpenSSL:インストール


  • インストール

brew install openssl

----------
==> Downloading http://openssl.org/source/openssl-1.0.1e.tar.gz
Already downloaded: /Library/Caches/Homebrew/openssl-1.0.1e.tar.gz
==> perl ./Configure --prefix=/usr/local/Cellar/openssl/1.0.1e --openssldir=/usr/local/etc/openssl zlib-dynamic shared d
==> make
==> make test
==> make install MANDIR=/usr/local/Cellar/openssl/1.0.1e/share/man MANSUFFIX=ssl
==> Caveats
To install updated CA certs from Mozilla.org:

brew install curl-ca-bundle

This formula is keg-only: so it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

The OpenSSL provided by OS X is too old for some software.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
/usr/local/Cellar/openssl/1.0.1e: 429 files, 15M, built in 3.7 minutes
----------


curl-ca-bundleインストール


  • インストール

brew install curl-ca-bundle

----------
==> Downloading https://downloads.sourceforge.net/project/machomebrew/mirror/curl-ca-bundle-1.87.tar.bz2
Already downloaded: /Library/Caches/Homebrew/curl-ca-bundle-1.87.tar.bz2
/usr/local/Cellar/curl-ca-bundle/1.87: 2 files, 252K, built in 2 seconds
----------


  • 証明書コピー

cp /usr/local/Cellar/curl-ca-bundle/1.87/share/ca-bundle.crt /usr/local/etc/openssl/cert.pem


Readline:インストール


  • インストール

brew install readline

----------
==> Downloading http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz
Already downloaded: /Library/Caches/Homebrew/readline-6.2.4.tar.gz
==> Patching
patching file callback.c
patching file input.c
patching file patchlevel
patching file support/shobj-conf
patching file vi_mode.c
==> ./configure --prefix=/usr/local/Cellar/readline/6.2.4 --mandir=/usr/local/Cellar/readline/6.2.4/share/man --infodir=
==> make install
==> Caveats
This formula is keg-only: so it was not symlinked into /usr/local.

OS X provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

LDFLAGS: -L/usr/local/opt/readline/lib
CPPFLAGS: -I/usr/local/opt/readline/include

==> Summary
/usr/local/Cellar/readline/6.2.4: 31 files, 1.6M, built in 17 seconds
----------


  • アップグレード

brew upgrade readline


Ruby 2.0.0-p0インストール

rbenv install 2.0.0-p0

----------
Downloading openssl-1.0.1e.tar.gz...
-> https://www.openssl.org/source/openssl-1.0.1e.tar.gz
Installing openssl-1.0.1e...
Installed openssl-1.0.1e to /Users/shu/.rbenv/versions/2.0.0-p0

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


5. デフォルト使用設定

rbenv global 2.0.0-p0

ruby -v
----------
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.1]
----------


6. バージョン確認

rbenv versions

----------
system
1.9.3-p327
1.9.3-p385
1.9.3-p392
* 2.0.0-p0 (set by /Users/shu/.rbenv/version)
----------

rbenv version

----------
2.0.0-p0 (set by /Users/shu/.rbenv/version)
----------


7. bundlerインストール

※2013/02/28:bundler1.3.0がリリースされたためpre/バージョン指定不要

gem i bundler

----------
Fetching: bundler-1.3.0.pre.gem (100%)
Successfully installed bundler-1.3.0.pre
Done installing documentation for bundler (0 sec).
1 gem installed
----------

gem list bundler

----------
*** LOCAL GEMS ***

bundler (1.3.0.pre)
----------



エラー対処

gem i bundler

----------
ERROR: Your gem push credentials file located at:

/Users/shu/.gem/credentials

has file permissions of 0644 but 0600 is required.

You should reset your credentials at:

https://rubygems.org/profile/edit

if you believe they were disclosed to a third party.
----------

chmod 600 /Users/shu/.gem/credentials


8. インストールしたRubyやGemのパスを通す

rbenv rehash


9. 各RailsアプリでGemインストール

Gemfile

source 'https://rubygems.org'

ruby "2.0.0"

cd RAILS_ROOT

bundle install




  • 「bundler-1.3.0.pre.8」だとbundle installエラー

bundle install

----------
Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!

/Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/net/http.rb:917:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/net/http.rb:917:in `block in connect'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/timeout.rb:51:in `timeout'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/net/http.rb:917:in `connect'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/net/http.rb:861:in `do_start'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/net/http.rb:856:in `start'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/vendor/net/http/persistent.rb:628:in `start'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/vendor/net/http/persistent.rb:570:in `connection_for'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/vendor/net/http/persistent.rb:930:in `request'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/fetcher.rb:169:in `fetch'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/fetcher.rb:151:in `use_api'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/source/rubygems.rb:223:in `block in remote_specs'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/source/rubygems.rb:223:in `select'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/source/rubygems.rb:223:in `remote_specs'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/source/rubygems.rb:162:in `fetch_specs'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/source/rubygems.rb:66:in `specs'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/lazy_specification.rb:52:in `__materialize__'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/spec_set.rb:86:in `block in materialize'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/spec_set.rb:83:in `map!'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/spec_set.rb:83:in `materialize'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/definition.rb:114:in `specs'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/definition.rb:109:in `resolve_remotely!'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/installer.rb:83:in `run'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/installer.rb:14:in `install'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/cli.rb:247:in `install'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/vendor/thor/task.rb:27:in `run'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/vendor/thor.rb:344:in `dispatch'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/vendor/thor/base.rb:434:in `start'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/bin/bundle:20:in `block in <top (required)>'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/lib/bundler/friendly_errors.rb:4:in `with_friendly_errors'
from /Users/shu/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/bundler-1.3.0.pre.8/bin/bundle:20:in `<top (required)>'
from /Users/shu/.rbenv/versions/2.0.0-p0/bin/bundle:23:in `load'
from /Users/shu/.rbenv/versions/2.0.0-p0/bin/bundle:23:in `<main>'
----------



  • Herokuに上げたら「ruby: symbol lookup error: 」エラー


    • おそらくThin => eventmachineがRuby2.0未対応のため。。



Feb 24 22:22:27 playcast-project app/web.1:  >> Thin web server (v1.5.0 codename Knife) 

Feb 24 22:22:27 playcast-project app/web.1: >> Maximum connections set to 1024
Feb 24 22:22:27 playcast-project app/web.1: >> Listening on 0.0.0.0:48969, CTRL+C to stop
Feb 24 22:22:27 playcast-project app/web.1: ruby: symbol lookup error: /app/vendor/bundle/ruby/2.0.0/gems/eventmachine-1.0.0/lib/rubyeventmachine.so: undefined symbol: rb_enable_interrupt

PumaならRuby2.0.0-p0+Herokuでも動きました。