fix(runtime): name ripgrep when Grep cannot run it - #5169
Open
Totoro-qaq wants to merge 2 commits into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withgrep_unavailableand a message that names ripgrep, gives a platform install command and the official install page. The local path looksrgup 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:
cwdexactly like a missing executable (spawn rg ENOENTboth ways). The local path only blames ripgrep after confirming the cwd still exists; a deleted session directory keeps its original error.brew upgraderemoves the old keg, the spawnENOENTwas normalized tonot_found("The requested path was not found.", marked recoverable), which reads as a missing search path. The worker runsrgfrom the filesystem root, so thatENOENTnow maps togrep_unavailablewith 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:
test:dist): 3,411 tests, 3,398 passed, 13 skipped, 0 failed.workspace-executor.test.tsandfilesystem-worker.test.ts. Onmainthe three conversion tests fail (ENOENT,not_found, and the old copy). The two guards, missing cwd keepsENOENTand a non-executablergkeepsEACCES, pass on both; removing the cwd check makes the missing-cwd guard fail.npm run lint,npm run format:check,npm run build(all workspaces),npm run typecheck, and knip forapps/desktopandpackages/ui. The ASF header check andgit diff --checkpass too.Local path with no
rgonPATH:Not run locally: Linux, Windows, and the suites of the workspaces downstream of runtime. CI covers them for this diff:
scripts/ci-test-plan.mjsselects the runtime, eval, computer-use, cli, desktop and runtime-host suites plus the Linux sandbox smoke, and thefilesystem-worker/**path filter triggers the Windows sandbox workflow. The packaged desktop app was not exercised.AI use
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
Does this PR entail a change in behavior?
🤖 Generated with Claude Code