What is Rbenv?

Rbenv, short for ruby environment, offers a very convenient and powerful way for you to easily manage multiple versions of Ruby. 



Why would you want to use Rbenv, rather than using the Ruby provided by the system?

The version of Ruby provided within the macOS system may cause issues, bugs, or errors with dependencies being used within your environment alongside with Apple's M1 silicon. It is also worth noting that some dependencies that are only compatible with newer versions of Ruby.


Rbenv offers many commands, such as install, which allows you to install whichever version of ruby you want. With Rbenv, you may conveniently switch through all installed versions of Ruby. The following steps listed below do not require sudo, meaning any user on a Managed Server plan can install this software. Obtain a Managed Server Plan to quickly get started!


Before you begin, check if your Managed Server has Ruby installed through Homebrew:




Installing Rbenv

Here are step-by-step instructions on how to install Rbenv in your user environment. Please note, once you have downloaded Rbenv and added it to your path, you must restart or source your shell profile to be able to run the rbenv command. You will be running the following commands within our terminal(shell).


  1. Download and Install Rbenv.
    git clone https://github.com/rbenv/rbenv.git ~/.rbenv


  2. Add Rbenv to your path. Please use the command related to the shell you are currently using. If you are unsure, you may check by running the command noted at the bottom of this page. It is important to add Rbenv to your path or else you will not be able to run rbenv without specifying the full path.
    • If you are using Bash.
      echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile


    • If you are using Zsh.
      echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc


  3. Add Rbenv shims to your path.

    • If you are using Bash.
      echo 'eval "$(rbenv init -)"' >> ~/.bash_profile


    • If you are using Zsh.

      echo 'eval "$(rbenv init -)"' >> ~/.zshrc


  4. Install Ruby build. Without this, you will not be able to use the Rbenv install command. There are a couple ways to install ruby build, and this method will install it as an Rbenv plugin.

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


  5. You can now install which ever Ruby version you want.

    rbenv install <command>


  6. Once you have added Rbenv to your path, please restart your shell and run the doctor script to check if your environment is set up correctly. If your environment is set-up correctly, the output of the doctor script should look like the output in the image attached below.

    curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash


  7. Here is a list of other useful commands that may help you amplify your Ruby environment.
    • If you want to see a list of ruby version that are available for install.
      rbenv install --list


    • If you want to upgrade your ruby-build.

      git -C /Users/temp/.rbenv/plugins/ruby-build pull


Note: 

If you want to check which shell you are using, you may easily do so by running the following command within terminal.

echo $SHELL





Interested in MacinCloud Managed Servers?

Visit the Managed Server Plan page to obtain a Managed server.


Do you require full root/admin privileges on a MacinCloud Server?

Find out more about MacinCloud Dedicated Server Plans.