The ripgrep package provides a recursive grep alternative written in Rust.
A network connection is needed for building this package. The system certificate store may need to be set up with make-ca before building this package.
Install ripgrep by running the following commands:
cargo build --profile=release-lto --features=pcre2
To run the test suite, issue: cargo test --features=pcre2.
Now, as the root user:
install -vDm755 target/release-lto/rg -t /usr/bin/
If you want to install the man page, execute the following command as the
root user:
target/release-lto/rg --generate man | install -vDm644 /dev/stdin /usr/share/man/man1/rg.1
If you wish to install shell completions, execute the relevant commands
for your shell(s) as the root
user:
target/release-lto/rg --generate complete-bash | install -vDm644 /dev/stdin /usr/share/bash-completion/completions/rg target/release-lto/rg --generate complete-fish | install -vDm644 /dev/stdin /usr/share/fish/vendor_completions.d/rg.fish target/release-lto/rg --generate complete-zsh | install -vDm644 /dev/stdin /usr/share/zsh/site-functions/_rg
--profile=release-lto: Upstream specified build
optimizations that might normally be present in the release profile in a
custom release-lto profile.
[4]
It's also worth note that upstream builds their release assets with the
release-lto profile.
--features=pcre2: This parameter links against a
PCRE2 library installed in LFS to provide support for features present in
the PCRE2 regex engine, including backreferences and look-around. This
functionality is exposed through the --pcre2 and
--engine rg flags.
[4]
These optimizations are defined in Cargo.toml. For
an explanation of what each does, reference
The Cargo Book's profiles chapter.
The custom profile is used because the developer often rebuilds ripgrep
with baseline release optimizations for development purposes, and LTO
slows the build significantly.
Upstream may have elected to define a release-lto profile following
this example.
For more information pertaining to this profile, see
this commit
and its referenced issues.