LoginSignup
2
1

More than 5 years have passed since last update.

rbenvをmacOS High Sierraにインストールする

Last updated at Posted at 2018-04-28

rbenvは複数バージョンのrubyを管理するツールです。

公式の手順を見て作業を進めたので記録を残しておきます。 環境はmacOS High Sierra 10.13.4(17E199)でinstallにはHomebrewを使いました。

まずrbenvをインストールします。

$ brew install rbenv

バージョンを確認しておきます。

$ rbenv --version
rbenv 1.1.1

rbenv initを実行すると必要な作業手順が表示されます。

$ rbenv init
# Load rbenv automatically by appending
# the following to ~/.bash_profile:

eval "$(rbenv init -)"

bash_profileを開きeval "$(rbenv init -)"を追記します。

$ cd ~
$ vi .bash_profile

編集後、bash_profileの再読込みを行います。

$ source .bash_profile

rbenv-doctorスクリプトを実行して正しくrbenvがセットアップされたかを確認します。

$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash  

Checking for `rbenv' in PATH: /usr/local/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20180424)
Counting installed Ruby versions: none
  There aren't any Ruby versions installed under `/Users/username/.rbenv/versions'.
  You can install Ruby versions like so: rbenv install 2.2.4
Checking RubyGems settings: OK
Auditing installed plugins: OK

インストールできるrubyの一覧を確認します。

$ rbenv install --list

下記コマンドでruby2.5.1をインストールします。

$ rbenv install 2.5.1

インストールされているversionを確認します。*がついているものが現在rbenvが参照しているrubyです。

$ rbenv versions
* system (set by /Users/username/.rbenv/version)
  2.5.1

rbenvがglobalに参照するrubyバージョンを変更します。変更後にrbenv versionsを実行するとバージョンが切り替わっているのがわかります。


$ rbenv global 2.5.1
$ rbenv versions
  system
* 2.5.1 (set by /Users/username/.rbenv/version)

色々使い方を知りたい場合、公式のREADMEが充実しているのでそこを読むと良いです。

2
1
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
2
1