Skip to content

fix(runtime): name ripgrep when Grep cannot run it - #5169

Open
Totoro-qaq wants to merge 2 commits into
apache:mainfrom
Totoro-qaq:fix/grep-missing-ripgrep
Open

fix(runtime): name ripgrep when Grep cannot run it#5169
Totoro-qaq wants to merge 2 commits into
apache:mainfrom
Totoro-qaq:fix/grep-missing-ripgrep

Conversation

@Totoro-qaq

Copy link
Copy Markdown
Contributor

Summary

Without ripgrep, every Grep call on the local path failed with a bare spawn rg ENOENT, and the filesystem worker said only "Grep is unavailable in this runtime." Both paths now fail with grep_unavailable and a message that names ripgrep, gives a platform install command and the official install page. The local path looks rg up on every call, so it says to retry; the worker resolves ripgrep once when the runtime starts, so it says to restart Maka.

Two cases needed more than new copy:

  • Node reports a missing spawn cwd exactly like a missing executable (spawn rg ENOENT both ways). The local path only blames ripgrep after confirming the cwd still exists; a deleted session directory keeps its original error.
  • The worker pins ripgrep's realpath at startup. If that file disappears later, for example when brew upgrade removes the old keg, the spawn ENOENT was normalized to not_found ("The requested path was not found.", marked recoverable), which reads as a missing search path. The worker runs rg from the filesystem root, so that ENOENT now maps to grep_unavailable with the stale path and a restart hint.

Exit code 1 still means no matches, and EACCES, timeouts and other spawn errors keep their current handling. The Windows sandbox refusal is unchanged. Shipping ripgrep with the product (Phase 2 in the issue) is out of scope.

Fixes #5167

Thanks to @colaforniaw for the analysis and the phased plan in the issue.

Verification

Local macOS arm64, Node 22.23.1, dependencies installed with npm 11.19.0:

  • Runtime suite (test:dist): 3,411 tests, 3,398 passed, 13 skipped, 0 failed.
  • Five new tests in workspace-executor.test.ts and filesystem-worker.test.ts. On main the three conversion tests fail (ENOENT, not_found, and the old copy). The two guards, missing cwd keeps ENOENT and a non-executable rg keeps EACCES, pass on both; removing the cwd check makes the missing-cwd guard fail.
  • The pre-push checks from CONTRIBUTING pass: npm run lint, npm run format:check, npm run build (all workspaces), npm run typecheck, and knip for apps/desktop and packages/ui. The ASF header check and git diff --check pass too.

Local path with no rg on PATH:

RipgrepUnavailableError [grep_unavailable]: Grep requires ripgrep (`rg`), which was not found on PATH. Install it with `brew install ripgrep`, or see https://github.com/BurntSushi/ripgrep#installation. Then retry.

Not run locally: Linux, Windows, and the suites of the workspaces downstream of runtime. CI covers them for this diff: scripts/ci-test-plan.mjs selects the runtime, eval, computer-use, cli, desktop and runtime-host suites plus the Linux sandbox smoke, and the filesystem-worker/** path filter triggers the Windows sandbox workflow. The packaged desktop app was not exercised.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Claude Code investigated the defect, authored the implementation and regression tests, ran local verification, and prepared the contribution drafts. Submitted with contributor approval.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

🤖 Generated with Claude Code

Grep failed with a bare `spawn rg ENOENT` on the local path and a
generic "Grep is unavailable in this runtime." in the filesystem worker.
Both now fail with grep_unavailable and copy that names ripgrep, an
install command and the next step (retry locally, restart Maka for the
worker).

The local path checks that the cwd still exists before blaming ripgrep,
because Node reports a missing spawn cwd with the same ENOENT. The
worker maps a spawn ENOENT for its startup-resolved executable to
grep_unavailable instead of not_found, which read as a missing search
path.

Fixes apache#5167

Generated-by: Claude Code
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The shared ripgrep copy is imported by the filesystem worker and the
builtin tools, so it joins the Windows package closure and the recovery
filter. Register the new POSIX-only EACCES test in the Windows skip
inventory as a platform contract.

Generated-by: Claude Code
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(runtime): surface and satisfy Grep's ripgrep dependency

1 participant