How to install ripgrep (rg) on macOS, Linux, and Windows

Install rg on three platforms, run your first regex search, and understand .gitignore filtering.

To search a codebase quickly, ripgrep (rg) beats grep -r for daily work: it respects .gitignore by default and parallelises well. This guide follows official install paths on macOS, Linux, and Windows for hereink readers.

The query is how to install ripgrep and search with regex. You should finish able to run your first rg at the project root and know how ignored files are skipped.

macOSHomebrew or release binary
LinuxPackage manager or cargo
Windowswinget / MSI / Scoop
install rgfirst searchgitignore rules

What ripgrep fixes

Fewer grep traps

grep -r walks into node_modules, dist, and .git unless you script exclusions. rg reads .gitignore, .ignore, and global ignore rules by default—better for finding symbols in a repo.

Regex without POSIX homework

rg uses the Rust regex engine: \d, groups, anchors, and more. You do not need full POSIX; literals, case flags, and type filters cover most day-one tasks.

Check the build in terminal: rg --version. Upstream repo: github.com/BurntSushi/ripgrep.

Install rg on all three OSes

  1. 1
    macOS (Homebrew)

    With Homebrew: brew install ripgrep. Verify with which rg and rg --version. Same formula on Apple Silicon and Intel.

  2. 2
    Linux (distro packages)

    Debian/Ubuntu: sudo apt update && sudo apt install ripgrep. Fedora: sudo dnf install ripgrep. Arch: sudo pacman -S ripgrep. If the repo lags, grab the matching tarball from GitHub Releases, unpack, and put rg on your PATH.

  3. 3
    Windows

    In PowerShell or Terminal: winget install BurntSushi.ripgrep.MSVC, or install the MSI from GitHub Releases. Scoop: scoop install ripgrep. Open a new shell and run rg --version.

  4. 4
    Optional: Rust toolchain

    If Rust is already installed: cargo install ripgrep. Slower compile, useful when no package exists.

Basic regex searches

# Literal (case-sensitive by default)
rg "useState" src/

# Case-insensitive
rg -i "error" .

# Regex: lines starting with function
rg "^function\s+\w+" --type js

# Filenames only
rg -l "TODO" .

# Line numbers with context
rg -n -C 2 "api/v1" 

From a repo root, rg walks upward to find .git, sets the project boundary, and applies ignore rules there.

.gitignore respect and exceptions

GoalCommandNote
Defaultrg patternSkips paths in .gitignore
Search ignored treesrg --no-ignore patternFor build artefacts or local configs; noisy
Extra excluderg --glob '!*.min.js' fooFilter on top of ignore rules
One extensionrg -t py "def main"-t and --type-list show built-in types
Fits
Finding component names, env vars, or TODOs in monorepos; tracing a CI log line back to a file.
Does not fit
Batch editing file contents (use an editor or sd/sed); indexing huge binary blobs (use specialised tools).
Can rg replace grep everywhere?

No. rg targets directory trees with ignore rules; grep shines in pipes and single files. Many teams keep both.

Why can’t I find strings inside node_modules?

Because node_modules is usually in .gitignore. Use rg --no-ignore or search inside that folder directly; expect slower, larger output.

Windows says rg is not recognised?

Close and reopen the terminal after install. Run where rg. winget/MSI should add PATH; manual zip installs need you to append the folder in user environment variables.

After the search, align the plan

Once terminal search points to files, architecture still benefits from one shared drawing. A short room needs no extra stack—see how to create a space.

Start a room