You are here
Home > IT > rbenvのインストールと設定

rbenvのインストールと設定

rubyのパスを一々手作業で設定するのは面倒なのでrbenvを設定する。いつもの引用から。

rbenvインストール

https://github.com/rbenv/rbenv#basic-github-checkout
sudo yum install git wget gcc make openssl-devel readline-devel
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
~/.rbenv/bin/rbenv init

vi ~/.bash_profile

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

eval "$(rbenv init - bash)"
一応再読み込み
. ~/.bash_profile
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash

Checking for `rbenv' in PATH: /home/ec2-user/.rbenv/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: not found
Unless you plan to add Ruby versions manually, you should install ruby-build.
Please refer to https://github.com/rbenv/ruby-build#installation

Counting installed Ruby versions: none
  There aren't any Ruby versions installed under `/home/ec2-user/.rbenv/versions'.
  You can install Ruby versions like so: rbenv install <version>
Checking RubyGems settings: OK
Auditing installed plugins: OK
mkdir -p "$(rbenv root)"/plugins
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

rubyをインストールする。

rbenv install --list    
2.6.7
2.7.3
3.0.1
jruby-9.2.17.0
mruby-3.0.0
rbx-5.0
truffleruby-21.1.0
truffleruby+graalvm-21.1.0

rbenv install 2.7.3
# rubyインストール
rbenv install 2.6.7

# rubyアンインストール
rbenv uninstall 2.6.7

# インストール反映
rbenv rehash

# デフォルト設定
rbenv global 2.7.3
rbenv local 2.7.3

# インストール済一覧
rbenv versions
  2.6.7
* 2.7.3 (set by /home/ec2-user/.rbenv/version)
Top