LoginSignup
3
6

More than 5 years have passed since last update.

rbenvでRubyのバージョン管理

Last updated at Posted at 2015-09-24

Xcodeに付随しているRubyを使わずに、rbenvでRubyを管理します。

brewでrbenvをインストール

Command
brew install rbenv
brew install ruby-build

rbenvを使用してrubyをインストール

インストール可能なRubyのバージョン一覧を表示する

Command
rbenv install --list
内容
Available versions:
  1.8.6-p383
  1.8.6-p420
  1.8.7-p249
  1.8.7-p302
  .
  .
  .
  ree-1.8.7-2012.01
  ree-1.8.7-2012.02
  topaz-dev

Rubyのインストール

現在の安定版である「ver: 2.2.0」をインストールをします。

Command
rbenv install 2.2.0

rbenvで管理しているRubyの一覧を確認する

Command
rbenv versions
表示される内容
* system
  2.2.0 (set by /Users/xxxxx/.rbenv/version)

Rubyバージョンの切り替え

Command
rbenv global 2.2.0

RubyのPATHを設定する

Command
vim ~/.bash_profile
追加する内容
# ruby setting
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

設定ファイルを読み込む

Command
source ~/.bash_profile

RubyのPATHが正しいことを確認する

Command
which ruby
表示内容
/Users/xxxxx/.rbenv/shims/ruby
3
6
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
3
6