Skip to content

Commit cdc8bd2

Browse files
committed
Clear bun install cache before auto-update
When bun caches a previous version of the package, auto-update may reinstall the cached (stale) version instead of the requested target version. This fix clears bun's install cache for @Tarquinen before running the update command, ensuring the correct version is installed.
1 parent 80f3a75 commit cdc8bd2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/version-checker.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,20 @@ export function isOutdated(local: string, remote: string): boolean {
5454

5555
export async function performUpdate(targetVersion: string, logger?: { info: (component: string, message: string, data?: any) => void }): Promise<boolean> {
5656
const cacheDir = join(homedir(), '.cache', 'opencode')
57+
const bunCacheDir = join(homedir(), '.bun', 'install', 'cache', '@tarquinen')
5758
const packageSpec = `${PACKAGE_NAME}@${targetVersion}`
5859

5960
logger?.info("version", "Starting auto-update", { targetVersion, cacheDir })
6061

62+
// Clear bun's install cache for this package to prevent stale versions
63+
try {
64+
const { rmSync } = await import('fs')
65+
rmSync(bunCacheDir, { recursive: true, force: true })
66+
logger?.info("version", "Cleared bun cache", { bunCacheDir })
67+
} catch (err) {
68+
logger?.info("version", "Could not clear bun cache", { error: (err as Error).message })
69+
}
70+
6171
return new Promise((resolve) => {
6272
let resolved = false
6373

0 commit comments

Comments
 (0)