This guide will not install a specific Ruby version you want, although, it will setup rbenv so you can manage multiple Ruby versions.
It assumes that the project that requires a specific Ruby version has a file .ruby-version in the root of the project. So, simply running rbenv install from project root directory will use the version specified in that file and install it.
But if you still want to install a specific version of Ruby without using .ruby-version file, you can do so using:
$ rbenv install 3.4.6This will get you going with the latest version of rbenv without needing a system-wide install.
-
Clone rbenv into
~/.rbenv:$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv -
Set up your shell to load rbenv:
$ ~/.rbenv/bin/rbenv init -
Restart your shell so that these changes take effect. (Opening a new terminal tab will usually do it.)
-
Verify the installation:
$ rbenv -v rbenv 1.3.2-10-gd1a19a3
Important
If the above command returns bash: rbenv: command not found..., it might be possible that the command in step 2 added the eval line in ~/.bash_profile and returned the output similar to below:
$ ~/.rbenv/bin/rbenv init
writing ~/.bash_profile: now configured for rbenv.You can also verify it in ~/.bash_profile:
$ nano ~/.bash_profile
# You'll find something similar to below, at the end of the file:
# Added by `rbenv init` on Tue Sep 16 10:58:16 AM PKT 2025
eval "$(~/.rbenv/bin/rbenv init - --no-rehash bash)"To fix the issue, remove these lines from ~/.bash_profile and add at the end of the ~/.bashrc file:
# Open the file:
nano ~/.bashrc
# Add the following:
# Added by `rbenv init` on Tue Sep 16 10:58:16 AM PKT 2025
eval "$(~/.rbenv/bin/rbenv init - --no-rehash bash)"Then, follow step 3 and 4 again.
The rbenv install command does not ship with rbenv out-of-the-box, but is provided by the ruby-build plugin.
To install ruby-build, run the following command:
$ git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-buildBefore attempting to install Ruby, check that your build environment has the necessary tools and libraries.
$ sudo dnf install autoconf gcc rust patch make bzip2 openssl-devel libyaml-devel libffi-devel readline-devel gdbm-devel ncurses-devel perl-FindBin zlib-ng-compat-develLet's say, you are in the root of your project directory (my_app) and a file .ruby-version exists with the following version:
# my_app/.ruby-version
3.4.6Now, running the following command will automatically look for the version specified in .ruby-version and install it:
$ rbenv installFrom your project directory (my_app), run the following command to verify the version rbenv is currently using for this project among other rubies you have previously installed (if any):
$ rbenv versions
3.4.5
* 3.4.6 (set by /home/ammar/workspace/projects/my_app/.ruby-version)The asterisk (*) in the above output indicates the currently active version.
$ rbenv global 3.4.6$ rbenv shell 3.4.6To remove old Ruby versions, simply rm -rf the directory of the version you want to remove. You can find the directory of a particular Ruby version with the rbenv prefix command, e.g. rbenv prefix 3.4.5.
$ rbenv versions
3.4.5
3.4.6
$ rbenv prefix 3.4.5
/home/ammar/.rbenv/versions/3.4.5
$ rm -rf /home/ammar/.rbenv/versions/3.4.5
$ rbenv versions
3.4.6$ git -C "$(rbenv root)" pull$ git -C "$(rbenv root)"/plugins/ruby-build pull