LoginSignup
12
12

More than 5 years have passed since last update.

brewとrbenvを使ってRuby2.1.2を突っ込む

Last updated at Posted at 2014-05-10

よく、sora_hさんの記事を参考にRubyを入れていたのですが、
readline問題などで最新のRubyでは落ちるので、
ここに最新版(2.1.2)のRubyを突っ込む方法を書いてみようと思います。

準備

Macにコンパイルに使うツールが入ってないので、

brewのインストール

パッケージマネージャーのhomebrewをインストールします。
本当は自分でパッケージを管理するのが良いですが、めんどくさいので、
brewに任せます。

 $ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

を実行し、homebrewをインストール

opensslのインストール

 $ brew install openssl

readlineのインストール

6.3だとビルドに失敗するため、過去のフォーミュラの6.2.4を入れます

 $ cd /usr/local
 $ git checkout 0181c8a Library/Formula/readline.rb
 $ brew install readline

rbenvなどのインストール

 $ brew install rbenv
 $ brew install ruby-build
 $ brew install rbenv-gemset
 $ brew install rbenv-gem-rehash

rubyのインストール

 # Rubyコンパイルを高速化
 $ export MAKEOPTS="-j8"
 $ CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline`" rbenv install 2.1.2

バージョン変更

通常使用するRubyのバージョンを変更します。

 $ rbenv global 2.1.2

確認

 $ ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]

お疲れ様でした。
不備などありましたら、コメントまでどうぞ。

12
12
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
12
12