Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save daviddenton/9c4257a8ad58228c7c8689f8881a20ad to your computer and use it in GitHub Desktop.
Save daviddenton/9c4257a8ad58228c7c8689f8881a20ad to your computer and use it in GitHub Desktop.
install ruby on ubuntu
rbenv is a Ruby version manager that allows you to install multiple versions of Ruby and switch between them. Follow the steps below to install Ruby using rbenv.
Install all required dependencies for the ruby-build plugin to download and compile Ruby.
console
Copy
$ sudo apt install autoconf patch build-essential rustc libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libgmp-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev libdb-dev libtool uuid-dev
Install the latest rbenv installation script.
console
Copy
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash
Add the rbenv path to the .bashrc file.
console
Copy
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
Reload the .bashrc shell configuration to apply the path changes in your active session.
console
Copy
$ source ~/.bashrc
View the installed rbenv version.
console
Copy
$ rbenv -v
Your output should be similar to the one below.
rbenv 1.3.0-9-gefeab7f
List all available Ruby versions you can install.
console
Copy
$ rbenv install -l
Note the target Ruby version in your output similar to the one below.
3.1.6
3.2.6
3.3.6
jruby-9.4.9.0
mruby-3.3.0
picoruby-3.0.0
truffleruby-24.1.1
truffleruby+graalvm-24.1.1
Only latest stable releases for each Ruby implementation are shown.
Use `rbenv install --list-all' to show all local versions.
Install your target Ruby version. For example, 3.3.6.
console
Copy
$ rbenv install 3.3.6
The installation process may take 3-5 minutes to complete depending on the available server resources.
Set the installed Ruby version as the default if the installation is successful.
console
Copy
$ rbenv global 3.3.6
View the installed Ruby version.
console
Copy
$ ruby --version
Your output should be similar to the one below.
ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment