# How to Install rbenv on Ubuntu or Debian-based System

If you’re a Ruby developer, you know how important it is to have a version manager that allows you to switch between different versions of Ruby. `rbenv` is a popular version manager for Ruby that makes it easy to install, manage, and switch between different versions of Ruby on your Unix-based system. In this tutorial, we’ll go through the steps of installing `rbenv` on your system. 🚀

### **Prerequisites** 🔧

Before we start, ensure your system has the necessary dependencies installed. On Ubuntu or Debian, you can use the following command to install them:

```bash
sudo apt-get update

sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev libffi-dev
```

On other systems, you may need to use a different package manager or install the dependencies manually.

### **Step 1: Install** `rbenv` 💡

The first step is to clone the `rbenv` repository from GitHub into your home directory:

```bash
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
```

### **Step 2:** Configure your shell to load `rbenv` 👨‍💻

The following commands should automatically load `rbenv` when you start your terminal.

* For **bash**:
    
    ```bash
    echo 'eval "$(~/.rbenv/bin/rbenv init - bash)"' >> ~/.bashrc
    ```
    
* For **Zsh**:
    
    ```bash
    echo 'eval "$(~/.rbenv/bin/rbenv init - zsh)"' >> ~/.zshrc
    ```
    
* For **Fish shell**:
    
    ```bash
    echo 'status --is-interactive; and ~/.rbenv/bin/rbenv init - fish | source' >> ~/.config/fish/config.fish
    ```
    

### **Step 3: Reload your shell configuration** 🤖

After you've added the lines to your shell configuration file, you need to reload your shell configuration. Run the following command to reload your shell configuration:

```bash
source ~/.bashrc
```

or

```bash
source ~/.zshrc
```

or for Fish shell:

```bash
source ~/.config/fish/config.fish
```

### **Step 4: Verify that** `rbenv` is installed 💻

To make sure that `rbenv` is installed correctly, run the following command:

```bash
rbenv --version
```

This should print the version of `rbenv` that you just installed.

### **Step 5: Install a Ruby version** 💎

The `rbenv install` command is not a part of `rbenv` but is provided by the [ruby-build](https://github.com/rbenv/ruby-build#readme) plugin.

To install `ruby-build` plugin, you can use the following command:

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

Finally, use `rbenv` to install a version of Ruby:

```bash
rbenv install <version>
```

Replace `<version>` with the version of Ruby that you want to install (such as `2.7.7`). Once the installation is complete, you can set this version as the global default or as the default for a specific project using `rbenv global` or `rbenv local`, respectively.

Congratulations! 🎉 You now have `rbenv` installed on your Unix-based system, and now you can easily use it to manage your Ruby versions.
