Ripgrep: How to Fix "rg Command Not Found"

Updated

Learn how to fix the rg: command not found error for ripgrep on Mac

Ripgrep: How to Fix rg Command Not Found

The rg: command not found error means ripgrep either isn't installed, or your terminal can't find it.

Install ripgrep

On a Mac, the easiest way to install it is with Homebrew. Open your terminal and run:

brew install ripgrep

Just note that the package is called ripgrep, but the command it installs is rg. Once it's done, run rg --version to make sure it works.

Fix your PATH

If you already installed it and still get the error, check where it lives with which rg. On Apple Silicon Macs, Homebrew installs to /opt/homebrew/bin, and that folder has to be on your PATH. Add it to your ~/.zshrc and reload it:

echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

You can also just close and reopen your terminal instead of running source.

undefined

If you installed ripgrep with Cargo instead, add $HOME/.cargo/bin to your PATH the same way.