Tested on Ubuntu 22.04 LTS (WSL), should work on other versions. Uninstall all pre-installed ruby installs first.
- Update apt repos first, always
$ sudo apt update
- Install needed tools
$ sudo apt install curl libssl-dev zlib1g-dev git gcc g++ default-jre -y
- Install rbenv
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash
- Init rbenv on startups
$ echo 'eval "$(~/.rbenv/bin/rbenv init - bash)"' >> ~/.bashrc
- Restart your terminal
$ rbenv install -l
- Install ruby and jruby
$ # Select the latest stable version of ruby and jruby. Then run:
$ rbenv install 'ruby version' --verbose
$ rbenv install 'jruby version' --verbose
- Set the default ruby version
$ rbenv global 'ruby version'