Setting up Ruby on Rails on a Mac

Similar to pyenv and nvm I’m using rvm (Ruby Version Manager) to manage my ruby versions. Brew is already on my machine so I now just need to install a few packages then then the latest Ruby version.

$ brew install gnupg

$ gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

If you receive

gpg: keyserver receive failed: Server indicated a failure

You can try the method below, the first one failed on my machine but the method below sailed through

$ gpg --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

We can now install rvm , the instructions are on their site also but first you’ll need to either restart terminal or use

$ source ~/.zshrc

You can check the latest version of ruby here, once you have the latest you can install it via rvm

$ rvm install 3.2.1

This could take a few minutes so maybe time for another Silicon Valley Episode, another great scene is Son of Anton debugging code!

If you run the command below you’ll still get the system version of ruby showing

$ ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin22]

So we need to tell rvm to set the default version to use

$ rvm --default use 3.2.1
$ ruby -v  
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [arm64-darwin22]

You can also create an alias for the default version

$ rvm alias create default 3.2.1

Oh, we just need to install Rails now…

$ gem install rails

Boom, we’re ready to go!