sajad torkamani

Install rbenv

Install required packages:

sudo apt-get install -y \
  build-essential \
  libssl-dev \
  zlib1g-dev

Clone rbenv git repo into $HOME/.rbenv:

git clone https://github.com/rbenv/rbenv.git $HOME/.rbenv

Add rbenv executable to your $PATH (if not already added to ~/.zshrc or ~/.bashrc):

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc

Set up rbenv in your shell (if not already added to ~/.zshrc):

~/.rbenv/bin/rbenv init

Add eval "$(rbenv init -)" to your .zshrc (if not already added).

Install ruby-build as an rbenv plugin

Create rbenv plugins folder:

mkdir -p "$(rbenv root)"/plugins

Checkout ruby-build git repo:

git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

Install Ruby version using rbenv

Install Ruby version:

# Install whatever version you like
rbenv install --verbose 3.1.0

Set installed version as default:

rbenv global 3.1.0

You might need to restart the terminal to use the new Ruby version.

Tagged: Ruby

Leave a comment

Your email address will not be published. Required fields are marked *