Install Ruby on Linux
Introduction
One thing well: rbenv is concerned solely with switching Ruby versions. It’s simple and predictable. If you’re not convenced, read Why choose rbenv over RVM.
** The below $PATH commands assume you are using .bashrc for your shell configs. If you are not, make the appropriate adjustments (~/.zshrc if you’re using zsh instead of bash, for example). If you have no idea what this means and want to learn, start with this article about startup file order.
Prerequisites
You will need to have Git installed and configured before beginning.
Install
Clone rbenv into ~/.rbenv and add ~/.rbenv/bin to your $PATH for access to the rbenv command-line utility.
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
Clone ruby-build into ~/.rbenv/plugins/ruby-build and add ~/.rbenv/plugins/ruby-build/bin to your $PATH for access via the command-line utility.
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
Install the latest version of Ruby.
rbenv install 2.5.1
rbenv global 2.5.1
Check that it installed properly.
ruby -v
Bundler
Install bundler for gem management.
gem install bundler