From 50cc641288e66479e0ef0a1e2de064a7f787d996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Haris=20Gu=C5=A1i=C4=87?= Date: Fri, 24 Oct 2025 01:05:01 +0200 Subject: [PATCH] fix: Opencode fails with ENOENT posix_spawn '/usr/bin/rg' (#3396) --- packages/opencode/src/file/ripgrep.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/opencode/src/file/ripgrep.ts b/packages/opencode/src/file/ripgrep.ts index d023f47c..f575154e 100644 --- a/packages/opencode/src/file/ripgrep.ts +++ b/packages/opencode/src/file/ripgrep.ts @@ -211,6 +211,16 @@ export namespace Ripgrep { } } + // Bun.spawn should throw this, but it incorrectly reports that the executable does not exist. + // See https://github.com/oven-sh/bun/issues/24012 + if (!(await fs.stat(input.cwd).catch(() => undefined))?.isDirectory()) { + throw Object.assign(new Error(`No such file or directory: '${input.cwd}'`), { + code: "ENOENT", + errno: -2, + path: input.cwd, + }); + } + const proc = Bun.spawn(args, { cwd: input.cwd, stdout: "pipe",