Grep tool: spawn 'rg' ENOENT on macOS v2.1.96 (regression of #15026)
Bug description
The Grep tool fails with ENOENT: no such file or directory, posix_spawn 'rg' on every invocation in Claude Code v2.1.96 on macOS. This is the same class of bug as #15026 / #43336, but manifesting on rg (the Grep tool) rather than pgrep.
Environment
- Claude Code version: 2.1.96
- Install method: VS Code extension (
~/.vscode/extensions/anthropic.claude-code-2.1.96-darwin-arm64/resources/native-binary/claude) - OS: macOS Darwin 25.4.0 (Apple Silicon, arm64)
- Shell: zsh
- System ripgrep:
/opt/homebrew/bin/rgv15.1.0 (Homebrew, Mach-O arm64, executable, runs standalone fine)
Error output
Every Grep tool invocation returns:
ENOENT: no such file or directory, posix_spawn 'rg'
Investigation
rgis installed and executable at/opt/homebrew/bin/rg:
````
$ /opt/homebrew/bin/rg --version
ripgrep 15.1.0
$ file /opt/homebrew/bin/rg
/opt/homebrew/bin/rg: Mach-O 64-bit executable arm64
/opt/homebrew/binIS in the Claude Code process environment perps eww:
````
$ ps eww -p <claude-pid> | tr ' ' '\n' | grep '^PATH='
PATH=/Users/.../.antigravity/.../bin:/Users/.../.local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:...
The first several PATH entries include /opt/homebrew/bin, yet the spawn still fails with ENOENT.
- The CC binary bundles ripgrep statically —
stringson the native binary reveals ripgrep's code (rg::search,RIPGREP_CONFIG_PATH, full help text) AND a literalcmd=\"rg\"spawn site. So the single-file binary contains ripgrep internally but still tries to spawnrgas an external command for the Grep tool, then fails.
- The Bash tool works fine — it resolves
rgvia its interactive shell snapshot. Only the native Grep tool's spawn path fails. This mirrors #43336's finding that Bun'sspawn()uses a different PATH resolution than the shell-snapshot-backed Bash tool.
Related issues
- #15026 — canonical
spawn pgrep ENOENTon macOS, closed stale - #43336 — v2.1.91 regression of the above on
pgrep, closed as duplicate of #15026. Root cause from that report: "Bun's subprocess spawning uses a restricted PATH that doesn't include/usr/bin" - #42068 — bundled
vendor/ripgrep/arm64-darwin/rglosing execute permission (different root cause, npm install only) - #20733 — stale vendored
rgpath after native installer migration, closed as duplicate
The pattern: Bun's spawn() in the CC single-file binary on macOS uses a restricted/cached PATH that doesn't agree with the parent process's PATH. Fixed once for pgrep, regressed; now manifesting on rg. Each instance is auto-closed as a duplicate of a stale parent, and the underlying Bun-spawn-PATH issue isn't resolved. Filing a fresh report rather than commenting on the locked duplicates.
Reproduction steps
- Install Claude Code v2.1.96 via the VS Code extension on macOS (Apple Silicon)
- Install ripgrep via Homebrew (
brew install ripgrep) — present at/opt/homebrew/bin/rg - Start a Claude Code session
- Invoke the Grep tool (e.g., search for any pattern)
- Observe
ENOENT: no such file or directory, posix_spawn 'rg'
Expected behaviour
Any of:
- Use the statically-bundled ripgrep inside the CC binary (it is already linked in)
- Resolve
rgvia an absolute path using a full PATH walk at spawn time - Fall back gracefully to the bundled copy when external
rgcan't be resolved
Workaround
Use the Bash tool with explicit /opt/homebrew/bin/rg. Works, but adds friction — compound-command permission prompts, no structured output, no glob/type filters.
4 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
The bot's three suggestions (#43336, #15026, #17626) are genuinely related — same class of bug, same spawn-ENOENT-via-restricted-PATH root cause — but all three are CLOSED, which is precisely the problem the original report calls out:
pgrepregression)pgrep, no resolution in thread)Commenting on a closed (and in some cases locked-after-7-days) issue doesn't reach triage, which is why I filed a fresh report rather than reviving a stale thread. The body explicitly describes this auto-close loop:
This bug is still present in the current release (v2.1.96) and now affects a different binary (
rg) than the prior reports (pgrep), breaking the Grep tool on every invocation — not an edge case, every call. The investigation section includes evidence the CC process env does contain/opt/homebrew/binperps eww, so it isn't a simple user-PATH misconfiguration.Please leave this open for human triage rather than auto-closing as a duplicate of already-closed issues.
Confirming this is no longer reproducible on Claude Code v2.1.101 (Homebrew
claude-code@latestcask, macOS Apple Silicon, arm64).Prior repro on this machine was on v2.1.91 (Homebrew
claude-codestable cask). Every Grep tool invocation returnedENOENT: no such file or directory, posix_spawn 'rg', exactly as described in OP — same/opt/homebrew/bin/rginstall (ripgrep 15.1.0). After upgrading to 2.1.101 (no changes torg, same PATH), the Grep tool works correctly.Looks like whatever landed between 2.1.96 and 2.1.101 resolved the Bun spawn PATH issue for
rg. Leaving this note for anyone finding this issue via search.This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.