6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

rbenvとruby-buildの正しいインストール方法

Posted at

Rubyのセットアップをしていて、rbenvruby-buildの設定で少しハマったので、備忘録。
なぜか知らないけど、ググってみてその通りに設定しても動かない。
あろうことか、公式ドキュメントでさえ微妙に間違っている!

以下のコマンドでインストールできるはす。

$ RBENV_ROOT=[***任意のrbenvのインストールPATH***]    # e.g. /usr/local/rubyenv ("/"で終わってはいけない)
$ git clone https://github.com/rbenv/rbenv.git $RBENV_ROOT
$ git clone https://github.com/rbenv/ruby-build.git $RBENV_ROOT/plugins/ruby-build
$ echo "export PATH=\$PATH:$RBENV_ROOT/bin" >> /etc/bashrc
$ echo "export RBENV_ROOT=$RBENV_ROOT" >> /etc/bashrc
$ echo 'eval "$(rbenv init -)"' >> /etc/bashrc

ポイントは、下2行の環境変数の設定あたり。
特に、環境変数RBENV_ROOTを設定しないと、ruby-buildへのPathが通らずにrbenv installが実行できない。

設定確認

# curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: /usr/local/rubyenv/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: which: no rbenv-install in (/usr/local/rubyenv/shims:/usr/local/rubyenv/shims:/usr/local/rubyenv/shims:/usr/local/rubyenv/shims:/usr/local/rubyenv/shims:/usr/local/rubyenv/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/rubyenv//bin:/root/bin:/usr/local/rubyenv/bin)
/usr/local/rubyenv/plugins/ruby-build/bin/rbenv-install (ruby-build 20180424)
Counting installed Ruby versions: none
  There aren't any Ruby versions installed under `/usr/local/rubyenv/versions'.
  You can install Ruby versions like so: rbenv install 2.2.4
Checking RubyGems settings: OK
Auditing installed plugins: OK

赤文字の警告が出なければOK!

6
4
1

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
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?