From 656f2990173eb5112ca82b770caad391a160c4ee Mon Sep 17 00:00:00 2001 From: BB84 <110078428+BB-84C@users.noreply.github.com> Date: Wed, 15 Jul 2026 10:26:50 -0400 Subject: [PATCH] fix(core): tolerate AlreadyExists in FSUtil.ensureDir (#36542) Co-authored-by: Aiden Cline --- packages/core/src/fs-util.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/core/src/fs-util.ts b/packages/core/src/fs-util.ts index eb68627a55..93a551c9b0 100644 --- a/packages/core/src/fs-util.ts +++ b/packages/core/src/fs-util.ts @@ -114,7 +114,14 @@ export namespace FSUtil { }) const ensureDir = Effect.fn("FileSystem.ensureDir")(function* (path: string) { - yield* fs.makeDirectory(path, { recursive: true }) + yield* fs.makeDirectory(path, { recursive: true }).pipe( + // Bun on Windows can throw EEXIST here despite recursive mode. + // https://github.com/oven-sh/bun/issues/21901 + Effect.catchIf( + (error) => error.reason._tag === "AlreadyExists", + (error) => isDir(path).pipe(Effect.flatMap((exists) => (exists ? Effect.void : Effect.fail(error)))), + ), + ) }) const writeWithDirs = Effect.fn("FileSystem.writeWithDirs")(function* (