Languages

Install Ruby

A current Ruby with gem and Bundler, separate from any Ruby your system came with.

  1. Install Ruby
    Terminal
    brew install ruby
  2. Use it instead of the old system Ruby
    Terminal
    echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc
    source ~/.zshrc
    echo "export PATH=\"$(gem environment gemdir)/bin:\$PATH\"" >> ~/.zshrc
    source ~/.zshrc

    macOS ships an outdated Ruby you shouldn't install gems into. The last two lines also put commands from installed gems (like rails) on your PATH.

Check it worked

  1. Check the versions
    Terminal
    ruby -v && gem -v && which ruby

    which ruby should show a path under /opt/homebrew.

Undo it
  1. Uninstall Ruby
    Terminal
    brew uninstall ruby
  1. Install RubyNeeds sudo
    Terminal · Ubuntu / Debian
    sudo apt install -y ruby-full
  2. Install gems in your home folder (no sudo needed)
    Terminal · Ubuntu / Debian
    echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc
    echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc
    source ~/.bashrc

Check it worked

  1. Check the versions
    Terminal · Ubuntu / Debian
    ruby -v && gem -v
Undo it
  1. Uninstall RubyNeeds sudo
    Terminal · Ubuntu / Debian
    sudo apt remove -y ruby-full
  1. Install Ruby with the DevKit
    PowerShell
    winget install RubyInstallerTeam.RubyWithDevKit.3.4

    The DevKit lets gems that need compiling install properly. Close and reopen PowerShell afterwards.

  2. Finish the DevKit setup
    PowerShell
    ridk install

    Press Enter to pick the default option.

Check it worked

  1. Check the versions
    PowerShell
    ruby -v; gem -v
Undo it
  1. Uninstall Ruby
    PowerShell
    winget uninstall RubyInstallerTeam.RubyWithDevKit.3.4