$ sudo apt-get update $ sudo apt-get install ruby ruby-dev
$ brew install firstname.lastname@example.org
In the case of macOS, you'll have to add this to your
PATH to run the custom Ruby.
If you had Ruby 2 running before you can leave this as is when using Ruby 3.
Note that both
bundler exist there.
$ which ruby bundler /usr/local/opt/ruby/bin/ruby /usr/local/opt/ruby/bin/bundler
$ ruby -v
$ bundle -v
This is to allow user level gems to run from anywhere.
If you like to install gems at the shared system level, like this, then you can skip this step.
$ gem install GEM_NAME $ # OR $ sudo gem install GEM_NAME
But if you like to install gems at the user level, like this, then you do need this step.
$ gem install GEM --user-install
Add the following to
if which ruby >/dev/null && which gem >/dev/null; then GEM_PATH="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin" export PATH="$GEM_PATH:$PATH" fi
Then start a new terminal tab to load the changes.
That shell command will figure out that path to your user gems, like this:
Then it will add the path to your
The best part is that it is dynamic - it does not have a hard-coded path. So Ruby can change where it decides to install gems (like it did between Ruby 2 and 3 from
~/.local). And you can upgrade from Ruby 3.0 to 3.1 or 4.0. Yet the shell command will figure out the correct path, without needing a manual update or causing head scratching when Ruby projects break one day.