Skip to content

Commit 5e9ec35

Browse files
committed
fix(environment): gracefully handle ripgrep not found during file listing
1 parent 865951c commit 5e9ec35

2 files changed

Lines changed: 26 additions & 12 deletions

File tree

src/core/environment/__tests__/getEnvironmentDetails.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,4 +446,14 @@ describe("getEnvironmentDetails", () => {
446446

447447
expect(getGitStatus).toHaveBeenCalledWith(mockCwd, 5)
448448
})
449+
450+
// Regression test for https://github.com/Zoo-Code-Org/Zoo-Code/issues/1024
451+
// When ripgrep cannot be found (e.g. @vscode/ripgrep >=1.18 platform layout on
452+
// Windows), listFiles throws "Could not find ripgrep binary". getEnvironmentDetails
453+
// must not propagate this — the task should proceed to the API call, not hang at 0%.
454+
it("should not throw when listFiles rejects with ripgrep not found", async () => {
455+
;(listFiles as Mock).mockRejectedValue(new Error("Could not find ripgrep binary"))
456+
457+
await expect(getEnvironmentDetails(mockCline as Task, true)).resolves.not.toThrow()
458+
})
449459
})

src/core/environment/getEnvironmentDetails.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -241,18 +241,22 @@ export async function getEnvironmentDetails(cline: Task, includeFileDetails: boo
241241
if (maxFiles === 0) {
242242
details += "(Workspace files context disabled. Use list_files to explore if needed.)"
243243
} else {
244-
const [files, didHitLimit] = await listFiles(cline.cwd, true, maxFiles)
245-
const { showRooIgnoredFiles = false } = state ?? {}
246-
247-
const result = formatResponse.formatFilesList(
248-
cline.cwd,
249-
files,
250-
didHitLimit,
251-
cline.rooIgnoreController,
252-
showRooIgnoredFiles,
253-
)
254-
255-
details += result
244+
try {
245+
const [files, didHitLimit] = await listFiles(cline.cwd, true, maxFiles)
246+
const { showRooIgnoredFiles = false } = state ?? {}
247+
248+
const result = formatResponse.formatFilesList(
249+
cline.cwd,
250+
files,
251+
didHitLimit,
252+
cline.rooIgnoreController,
253+
showRooIgnoredFiles,
254+
)
255+
256+
details += result
257+
} catch (error) {
258+
details += `(File listing unavailable: ${error instanceof Error ? error.message : String(error)})`
259+
}
256260
}
257261
}
258262
}

0 commit comments

Comments
 (0)