From f67b605f7a7a6e3e3d09cf51f3c94ca109298d19 Mon Sep 17 00:00:00 2001 From: SeeYouCowboi Date: Wed, 4 Mar 2026 16:48:33 +0800 Subject: [PATCH] fix: also invalidate plugin from CACHE_DIR in invalidatePackage Fix #2289 invalidatePackage() only removed the plugin from USER_CONFIG_DIR/node_modules/, but bun may install it in CACHE_DIR/node_modules/ on some systems. This left a stale copy behind, causing the startup toast to keep showing the old version even after the auto-update completed successfully. Now both candidate locations are checked and removed so the reinstalled version is loaded on the next restart. --- src/hooks/auto-update-checker/cache.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/hooks/auto-update-checker/cache.ts b/src/hooks/auto-update-checker/cache.ts index e5df33df7..9cf312a36 100644 --- a/src/hooks/auto-update-checker/cache.ts +++ b/src/hooks/auto-update-checker/cache.ts @@ -1,6 +1,6 @@ import * as fs from "node:fs" import * as path from "node:path" -import { PACKAGE_NAME, USER_CONFIG_DIR } from "./constants" +import { CACHE_DIR, PACKAGE_NAME, USER_CONFIG_DIR } from "./constants" import { log } from "../../shared/logger" interface BunLockfile { @@ -48,17 +48,22 @@ function removeFromBunLock(packageName: string): boolean { export function invalidatePackage(packageName: string = PACKAGE_NAME): boolean { try { - const pkgDir = path.join(USER_CONFIG_DIR, "node_modules", packageName) + const pkgDirs = [ + path.join(USER_CONFIG_DIR, "node_modules", packageName), + path.join(CACHE_DIR, "node_modules", packageName), + ] const pkgJsonPath = path.join(USER_CONFIG_DIR, "package.json") let packageRemoved = false let dependencyRemoved = false let lockRemoved = false - if (fs.existsSync(pkgDir)) { - fs.rmSync(pkgDir, { recursive: true, force: true }) - log(`[auto-update-checker] Package removed: ${pkgDir}`) - packageRemoved = true + for (const pkgDir of pkgDirs) { + if (fs.existsSync(pkgDir)) { + fs.rmSync(pkgDir, { recursive: true, force: true }) + log(`[auto-update-checker] Package removed: ${pkgDir}`) + packageRemoved = true + } } if (fs.existsSync(pkgJsonPath)) {