Ruby Cheatsheet


Install


Install old version from repository & rbenv :

sudo apt install ruby rbenv

Update ruby-build for rbenv :

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

Initialize rbenv and add the returned command to your ~/.bash_profile :

rbenv init

The command to add to your ~/.bash_profile :

eval "$(rbenv init -)"

Start a new console.


rbenv


Update latest list of available versions if needed :

git -C "$(rbenv root)"/plugins/ruby-build pull

List all available versions :

rbenv install --list

Install a specific version (no YJIT) :

rbenv install [specific_version]

Install a specific version (with YJIT) :

apt install rustc
RUBY_CONFIGURE_OPTS="--enable-yjit" rbenv install [specific_version]

Set a specific version as the default for all consoles / everything / only the current directory :

rbenv shell [specific_version]
rbenv global [specific_version]
rbenv local [specific_version]