日. 1月 29th, 2023

はじめに

rubyを自由にversion切り替えられるrbenvはとても便利。

しかし、インストールは少しめんどくさい。

よく使う手順なのでとりあえず晒す

手順

以下、コピペでOK。

インストールしたいversionは適宜変更すること

yum -y install openssl-devel readline-devel zlib-devel libcurl-devel git
cd /usr/local
git clone https://github.com/sstephenson/rbenv.git rbenv
mkdir rbenv/shims rbenv/versions rbenv/plugins
groupadd rbenv
chgrp -R rbenv rbenv
chmod -R g+rwxXs rbenv
cd /usr/local/rbenv/plugins
git clone https://github.com/sstephenson/ruby-build.git ruby-build
chgrp -R rbenv ruby-build
chmod -R g+rwxs ruby-build
git clone https://github.com/sstephenson/rbenv-default-gems.git rbenv-default-gems
chgrp -R rbenv rbenv-default-gems
chmod -R g+rwxs rbenv-default-gems

cat << EOF > /etc/profile.d/rbenv.sh
export RBENV_ROOT="/usr/local/rbenv" 
export PATH="\$RBENV_ROOT/bin:\$PATH" 
eval "\$(rbenv init -)" 
EOF

cat /etc/profile.d/rbenv.sh

cat << EOF > /usr/local/rbenv/default-gems
bundler
rbenv-rehash
EOF

cat /usr/local/rbenv/default-gems
source /etc/profile.d/rbenv.sh
rbenv install -l

yum install gcc bzip2
rbenv install 2.2.5
rbenv global 2.2.5
ruby -v

yum install rubygems -y

Good ruby life!