From 642950a76360a8669fda475757a3a110890e4ef4 Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Mon, 20 Jul 2026 16:02:24 -0400 Subject: [PATCH] fix(cli): isolate bun updater cache --- packages/cli/src/services/updater.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/services/updater.ts b/packages/cli/src/services/updater.ts index fd46b90084..ea0e70fab5 100644 --- a/packages/cli/src/services/updater.ts +++ b/packages/cli/src/services/updater.ts @@ -118,13 +118,21 @@ export const layer = Layer.effect( const upgrade = Effect.fnUntraced(function* (method: Method, version: string) { const target = `${packageName}@${version}` - const commands: Record = { + const commands: Record, string[]> = { npm: ["npm", "install", "--global", target], pnpm: ["pnpm", "install", "--global", target], - bun: ["bun", "install", "--global", target], yarn: ["yarn", "global", "add", target], } - const result = yield* run(commands[method], "5 minutes") + const result = yield* (method === "bun" + ? Effect.scoped( + Effect.gen(function* () { + // Bun does not prune old versions from its shared package cache. + yield* fs.makeDirectory(global.cache, { recursive: true }) + const cache = yield* fs.makeTempDirectoryScoped({ directory: global.cache, prefix: "update-" }) + return yield* run(["bun", "install", "--global", "--cache-dir", cache, target], "5 minutes") + }), + ) + : run(commands[method], "5 minutes")) if (result.code === 0) return return yield* Effect.fail(new Error(result.stderr.trim() || `Failed to update with ${method}`)) })