Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

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!

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away