Installing Ruby using rbenv on your WSL Ubuntu system

Installing Ruby using rbenv on your WSL Ubuntu system is a great way to manage multiple Ruby versions. Below are the step-by-step instructions:

Step 1: Update Your Package List

First, ensure your package list is up to date.

sudo apt upda…


This content originally appeared on DEV Community and was authored by Jess Alejo

Installing Ruby using rbenv on your WSL Ubuntu system is a great way to manage multiple Ruby versions. Below are the step-by-step instructions:

Step 1: Update Your Package List

First, ensure your package list is up to date.

sudo apt update

Step 2: Install Dependencies

Install the necessary dependencies for rbenv and Ruby.

sudo apt install -y build-essential libssl-dev libreadline-dev zlib1g-dev libffi-dev libyaml-dev

Step 3: Install rbenv

Clone the rbenv repository from GitHub and add it to your shell.

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
~/.rbenv/bin/rbenv init

Step 4: Install ruby-build

Clone the ruby-build repository into the rbenv plugins directory.

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

Step 5: Install Ruby

List all available Ruby versions.

rbenv install -l

Install your desired Ruby version (replace 3.3.4 with the version you want to install).

rbenv install 3.3.4
rbenv global 3.3.4 # to activate this Ruby version as the new default

Step 6: Verify the Installation

Check the Ruby version to ensure it was installed correctly.

ruby -v

Step 7: Install Bundler

Install the Bundler gem, which is essential for managing Ruby project dependencies.

gem install bundler

Step 8: Rehash rbenv

Rehash rbenv to ensure it recognizes the new Ruby installation.

rbenv rehash

Additional Notes

  • Updating rbenv and ruby-build: Occasionally, you might need to update rbenv and ruby-build. You can do this by navigating to their respective directories and pulling the latest changes from GitHub:
cd ~/.rbenv
git pull
cd ~/.rbenv/plugins/ruby-build
git pull
  • Switching Ruby Versions: To switch Ruby versions, simply install the desired version and set it globally or locally for a specific project:
rbenv install x.x.x
rbenv global x.x.x  # For system-wide
# or
rbenv local x.x.x   # For a specific project

Following these steps will help you successfully install and manage Ruby versions using rbenv on your WSL Ubuntu system.


This content originally appeared on DEV Community and was authored by Jess Alejo


Print Share Comment Cite Upload Translate Updates
APA

Jess Alejo | Sciencx (2024-08-10T04:24:10+00:00) Installing Ruby using rbenv on your WSL Ubuntu system. Retrieved from https://www.scien.cx/2024/08/10/installing-ruby-using-rbenv-on-your-wsl-ubuntu-system/

MLA
" » Installing Ruby using rbenv on your WSL Ubuntu system." Jess Alejo | Sciencx - Saturday August 10, 2024, https://www.scien.cx/2024/08/10/installing-ruby-using-rbenv-on-your-wsl-ubuntu-system/
HARVARD
Jess Alejo | Sciencx Saturday August 10, 2024 » Installing Ruby using rbenv on your WSL Ubuntu system., viewed ,<https://www.scien.cx/2024/08/10/installing-ruby-using-rbenv-on-your-wsl-ubuntu-system/>
VANCOUVER
Jess Alejo | Sciencx - » Installing Ruby using rbenv on your WSL Ubuntu system. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/10/installing-ruby-using-rbenv-on-your-wsl-ubuntu-system/
CHICAGO
" » Installing Ruby using rbenv on your WSL Ubuntu system." Jess Alejo | Sciencx - Accessed . https://www.scien.cx/2024/08/10/installing-ruby-using-rbenv-on-your-wsl-ubuntu-system/
IEEE
" » Installing Ruby using rbenv on your WSL Ubuntu system." Jess Alejo | Sciencx [Online]. Available: https://www.scien.cx/2024/08/10/installing-ruby-using-rbenv-on-your-wsl-ubuntu-system/. [Accessed: ]
rf:citation
» Installing Ruby using rbenv on your WSL Ubuntu system | Jess Alejo | Sciencx | https://www.scien.cx/2024/08/10/installing-ruby-using-rbenv-on-your-wsl-ubuntu-system/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.