LoginSignup
67
67

More than 5 years have passed since last update.

Homebrew + rbenv + ruby-buildでruby 2.0.0-p0をインストール

Last updated at Posted at 2013-03-05

他の方も既に書かれていますが、自分用のメモだからいいよね。。Homebrewはインストール済み。

0. 準備 (HomebrewのFormulaのupdate)

まず、

brew update

でHomebrewのFormulaをアップデート。

1. openssl、readlineのインストール

brew install openssl
brew install readline

でインストールする。
openssl、readlineがHomebrewで既にインストール済みならば

brew upgrade openssl
brew upgrade readline

でアップグレードする。

2. ruby-buildをインストール

brew install --HEAD ruby-build

でruby-buildをインストール。

既にruby-buildをインストールしている場合、HEADをインストールしたいので、

brew uninstall ruby-build

で一度アンインストールしてからruby-buildをインストールする。

3. rbenvのインストール

rbenvをインストールしていなければ、

brew install rbenv

でインストールする。

4. ruby 2.0.0-p0をインストール

rbenv install -l

2.0.0-p0があることを確認する。

RUBY_CONFIGURE_OPTS="--with-readline-dir=`brew --prefix readline` --with-openssl-dir=`brew --prefix openssl`" rbenv install 2.0.0-p0 

でruby 2.0.0-p0をインストールする。

rbenv rehash
rbenv global 2.0.0-p0

のあと、ruby -v2.0.0p0が出力されれば、ひとまずインストールは完了。

4. キーワード引数を使って動作確認

ruby 2.0.0で新しく追加されたキーワード引数を使って動作確認をしてみましょう。
irbを起動して以下のスクリプトを試してみる。

def hoge(a :'a', b:'hanyaaaan')
  puts a
  puts b
end

hoge(a: 'hoehoe')

# hoehoe
# hanyaaaan

5. bundlerのインストール

bundlerをインストールしてみる。

gem -vでgemのバージョンを確認すると2.0.0となっている。

gem install bundlerでbundlerをインストールする。

bundle -vでバージョンを確認すると1.3.1となりました。

補足 bundle installで証明書エラーとなった場合の対処

bundle installすると、証明書のエラーが発生し、インストールできない場合がある。そんな時は以下のように証明書を設定する。

$ brew install curl-ca-bundle
$ cp /usr/local/Cellar/curl-ca-bundle/1.87/share/ca-bundle.crt /usr/local/etc/openssl/cert.pem 
67
67
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
67
67