Setting up Ruby

Setting up Ruby

September 15, 2023

So you heard about this really cool language called Ruby. Perhaps you’re here to learn Rails, or maybe you were enchanted by the elegance and simplicity that Ruby promises. Perhaps you’re a seasoned Rubyist and just got a new machine and need to set it up again (yay). Whatever the reason, we’ve got you covered. Let’s get your environment set up and ready to rock!

To install Ruby, I normally reach out to my favorite tool for the job: rvm. I use rvm because it helps me manage multiple versions of Ruby on my machine. I often work on various Ruby projects that require different versions of Ruby, so rvm is amazing for letting me switch between them with ease.

Run the following in your terminal:

\curl -sSL https://get.rvm.io | bash -s stable

This should install rvm on your machine and be a fairly quick process. At its core, rvm is a fairly sophisticated bash script.

Once installed, let’s install the prerequisites you need to get ruby running:

rvm requirements run

Now you’re ready to install the latest version of ruby:

rvm install 3.2.2

Once completed, run the following to see if ruby successfully installed and check its version:

ruby -v

You can also run the list command to see what versions are currently installed and which version of Ruby is currently in use:

rvm list

When you use the ‘cd’ command to navigate to a directory that contains a Ruby project and a .ruby-version file, it should automatically switch your Ruby version to the current version that the project supports. Pretty nifty!

Stay tuned for the next installment where I help you setup rails!