BurntSushi/ripgrep
Getting started
This page covers what you need to build, run, and test ripgrep from a fresh checkout. For end-user installation (Homebrew, apt, etc.) see the project README.
Prerequisites
- Rust 1.85.0 or newer (declared by
rust-version = "1.85"inCargo.toml). Install via rustup. - A C compiler, only needed if you build with the optional
pcre2feature and the system has nopkg-config-discoverable PCRE2. - musl toolchain, only needed if you want a fully static Linux binary (
rustup target add x86_64-unknown-linux-musl).
Build the binary
From the repository root:
cargo build --release
./target/release/rg --versionOptional PCRE2 support:
cargo build --release --features pcre2
./target/release/rg -P 'lookahead(?=here)' file.txtripgrep's [profile.release] in Cargo.toml keeps debug = 1 so backtraces are useful. There is also a release-lto profile with full LTO that the official release artifacts use.
Build a Debian package
The package.metadata.deb section in Cargo.toml defines Debian packaging. The ci/build-deb script (referenced from the README) runs cargo deb with the pcre2 feature enabled. The .deb profile inherits from release-lto.
Run tests
ripgrep has both unit tests inside each crate and an integration test suite that drives the compiled rg binary.
cargo test --allThe integration tests live under tests/ and are wired through tests/tests.rs:
| File | Purpose |
|---|---|
tests/feature.rs |
End-to-end coverage of CLI features (most flag combinations) |
tests/regression.rs |
Regression tests captured from past bug reports |
tests/json.rs |
The --json output format |
tests/multiline.rs |
The -U/--multiline mode |
tests/binary.rs |
Binary file detection and handling |
tests/misc.rs |
Catch-all for tests that don't fit elsewhere |
tests/util.rs |
Test harness: builds rg commands, captures output, compares results |
The tests/data/ directory holds canned haystacks used by these tests. See Testing for more.
Run linters
ripgrep uses rustfmt (config in rustfmt.toml) and clippy for code quality.
cargo fmt --check
cargo clippy --allCI also builds with the pcre2 feature and runs against the MSRV. The full CI matrix is in .github/workflows/ci.yml.
Run ripgrep against the repository itself
./target/release/rg 'fn main' --type rust
./target/release/rg --files --type-list # inspect built-in file types
./target/release/rg -uuu 'TODO' # disable all default filteringGenerating man page and shell completions
The rg binary itself can produce its man page and shell completion scripts:
./target/release/rg --generate man > rg.1
./target/release/rg --generate complete-bash > rg.bash
./target/release/rg --generate complete-zsh > _rg
./target/release/rg --generate complete-fish > rg.fish
./target/release/rg --generate complete-powershell > _rg.ps1The implementations live under crates/core/flags/doc/ and crates/core/flags/complete/.
Where to go next
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.