charmbracelet/crush · error
ripgrep not found in $PATH
Error message
ripgrep not found in $PATH
What it means
The grep tool's ripgrep-based search path could not locate the rg executable, so getRipgrepSearchCmd returned nil. The tool requires ripgrep as an external dependency and cannot perform the search without it.
Solutions
- Install ripgrep: `brew install ripgrep`, `apt install ripgrep`, `dnf install ripgrep`, or `cargo install ripgrep`
- Confirm `rg --version` runs in the same shell/environment crush uses
- Fix PATH so it includes rg's directory (e.g. export PATH="$HOME/.cargo/bin:$PATH")
- Restart crush after installing so the PATH lookup succeeds
Example fix
// before
cmd := getRgSearchCmd(ctx, pattern, path, include)
if cmd == nil {
return nil, fmt.Errorf("ripgrep not found in $PATH")
}
// after
cmd := getRgSearchCmd(ctx, pattern, path, include)
if cmd == nil {
return nil, fmt.Errorf("ripgrep not found in $PATH; install it with 'brew install ripgrep' or 'apt install ripgrep'")
} Defensive patterns
Strategy: fallback
Validate before calling
if _, err := exec.LookPath("rg"); err != nil {
// rg unavailable — skip ripgrep path or warn the user to install it
} Type guard
null
Try / catch
cmd := getRgSearchCmd(ctx, pattern, path, include)
if cmd == nil {
return nil, fmt.Errorf("ripgrep not found in $PATH")
} Prevention
- Install ripgrep as part of environment setup (Dockerfile, CI, devcontainer)
- Verify with `rg --version` after any toolchain change
- Include ripgrep's install dir (e.g. ~/.cargo/bin) in PATH
- Consider bundling rg or falling back to a pure-Go search when absent
When it happens
Trigger: searchWithRipgrep is invoked and getRgSearchCmd(ctx, pattern, path, include) returns nil — i.e. exec.LookPath("rg") fails because ripgrep is not installed or not on PATH.
Common situations: Fresh machines or CI containers without ripgrep; minimal Docker images; PATH modified so rg's location (e.g. /usr/local/bin, ~/go/bin, ~/.cargo/bin) is missing; crush installed via a method that doesn't bundle rg.
Related errors
- docker mcp is not available, please ensure docker is…
- could not run command
- could not run command
- failed to configure providers
- failed to get current user
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/c9835a775bfe3623.
Report an issue: GitHub.
Appendix: source
Thrown at internal/agent/tools/grep.go:221
// Use a stable sort so that the multiple matches a single file can
// contribute (all sharing the same modTime) keep their original
// line order and stay grouped together in the rendered output.
sort.SliceStable(matches, func(i, j int) bool {
return matches[i].modTime.After(matches[j].modTime)
})
truncated := len(matches) > limit
if truncated {
matches = matches[:limit]
}
return matches, truncated, nil
}
func searchWithRipgrep(ctx context.Context, pattern, path, include string) ([]grepMatch, error) {
cmd := getRgSearchCmd(ctx, pattern, path, include)
if cmd == nil {
return nil, fmt.Errorf("ripgrep not found in $PATH")
}
// Only add ignore files if they exist
for _, ignoreFile := range []string{".gitignore", ".crushignore"} {
ignorePath := filepath.Join(path, ignoreFile)
if _, err := os.Stat(ignorePath); err == nil {
cmd.Args = append(cmd.Args, "--ignore-file", ignorePath)
}
}
output, err := cmd.Output()
if err != nil {
if exitErr, ok := err.(*exec.ExitError); ok && exitErr.ExitCode() == 1 {
return []grepMatch{}, nil
}
return nil, err
}
View on GitHub (pinned to 7944b8e522)