- Install Ruby
brew install ruby - Use it instead of the old system Ruby
echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc source ~/.zshrc echo "export PATH=\"$(gem environment gemdir)/bin:\$PATH\"" >> ~/.zshrc source ~/.zshrcmacOS 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
- Check the versions
ruby -v && gem -v && which rubywhich ruby should show a path under /opt/homebrew.
Undo it
- Uninstall Ruby
brew uninstall ruby
- Install RubyNeeds sudo
sudo apt install -y ruby-full - Install gems in your home folder (no sudo needed)
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc source ~/.bashrc
Check it worked
- Check the versions
ruby -v && gem -v
Undo it
- Uninstall RubyNeeds sudo
sudo apt remove -y ruby-full
- Install Ruby with the DevKit
winget install RubyInstallerTeam.RubyWithDevKit.3.4The DevKit lets gems that need compiling install properly. Close and reopen PowerShell afterwards.
- Finish the DevKit setup
ridk installPress Enter to pick the default option.
Check it worked
- Check the versions
ruby -v; gem -v
Undo it
- Uninstall Ruby
winget uninstall RubyInstallerTeam.RubyWithDevKit.3.4