LoginSignup
118
118

More than 5 years have passed since last update.

Mountain Lion環境への「rbenv」のインストール手順 + 設定方法

Last updated at Posted at 2013-08-30

1. はじめに

本書では、Rubyのバージョン管理をする際に使用する「rbenv」のMacOS環境でのインストール手順及び設定方法について記述します。

2. 前提条件

  • MacOSのバージョンが 10.8.4 であること。(2013/8/30時点の最新バージョン)
  • Homebrewがインストールされていること。 (バージョン : 0.9.4)

3. インストール手順

(1) Homebrewを使ってrbenvとruby-buildをインストールします。

$ brew install rbenv ruby-build

(2) rbenvのパスを追加します。

$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
$ echo 'export PATH="$HOME/.rbenv/shims:$PATH"' >> ~/.bash_profile
$ source ~/.bash_profile

4. 設定方法

(1) 以下のコマンドを実行し、rbenvでインストールが可能なRubyのバージョンを確認します。

$ rbenv install -l

(2) インストールしたいRubyのバージョンを指定し、Rubyをインストールします。

$ rbenv install (バージョン名) # バージョンが1.9.3-p392のRubyをインストールする場合は 「rbenv install 1.9.3-p392」を実行します。

(3) 以下のコマンドを実行します。

$ rbenv rehash

(4) 以下のコマンドを実行し、上記のRubyがインストールされていることを確認します。

$ rbenv versions

(5) 以下のコマンドを実行し、MacOSでRubyが使えるように設定します。
*) ここでは「1.9.3-p392」をインストールしていることを前提にしています。必要に応じて読み替えてください。

$ rbenv shell 1.9.3-p392 # 現在実行しているシェル環境上の設定
$ rbenv global 1.9.3-p392 # システム全体の設定

5. 不要なバージョンのRubyを削除する場合

以下のコマンドを実行します。

$ rbenv uninstall -f (バージョン名) # バージョンが1.9.3-p392のRubyを削除する場合は 「rbenv uninstall -f 1.9.3-p392」を実行します。
$ rbenv rehash
$ rbenv versions # 対象のバージョンが削除されていることを確認します。
118
118
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
118
118