Skip to content

fix: also invalidate plugin from CACHE_DIR in invalidatePackage#2291

Merged
acamq merged 1 commit intocode-yeongyu:devfrom
SeeYouCowboi:fix/cache-dir-invalidation-stale-version
Mar 7, 2026
Merged

fix: also invalidate plugin from CACHE_DIR in invalidatePackage#2291
acamq merged 1 commit intocode-yeongyu:devfrom
SeeYouCowboi:fix/cache-dir-invalidation-stale-version

Conversation

@SeeYouCowboi
Copy link
Copy Markdown
Contributor

@SeeYouCowboi SeeYouCowboi commented Mar 4, 2026

Summary

Fixes #2289

invalidatePackage() only removed the stale plugin from USER_CONFIG_DIR/node_modules/, but on some systems bun installs the plugin into CACHE_DIR/node_modules/ instead. This left the old version untouched, so getCachedVersion() would keep reading the stale copy via import.meta.url traversal, causing the startup toast to show the old version even after the auto-updater ran successfully.

Root Cause

constants.ts defines two separate directories:

  • USER_CONFIG_DIR = ~/.config/opencode/ (where config lives)
  • CACHE_DIR = ~/.cache/opencode/ on Linux/macOS, %LOCALAPPDATA%\opencode on Windows

invalidatePackage() was only checking USER_CONFIG_DIR/node_modules/oh-my-opencode/. If bun placed the plugin in CACHE_DIR/node_modules/, the stale directory was never removed.

Change

src/hooks/auto-update-checker/cache.ts — check and remove the plugin from both candidate directories:

// Before
const pkgDir = path.join(USER_CONFIG_DIR, "node_modules", packageName)
if (fs.existsSync(pkgDir)) {
  fs.rmSync(pkgDir, { recursive: true, force: true })
  packageRemoved = true
}

// After
const pkgDirs = [
  path.join(USER_CONFIG_DIR, "node_modules", packageName),
  path.join(CACHE_DIR, "node_modules", packageName),
]
for (const pkgDir of pkgDirs) {
  if (fs.existsSync(pkgDir)) {
    fs.rmSync(pkgDir, { recursive: true, force: true })
    packageRemoved = true
  }
}

PR Checklist

  • Code follows project conventions
  • No version changes in package.json
  • Minimal change — only the affected function is modified

Summary by cubic

Ensures auto-updated plugins load correctly by removing stale installs from both USER_CONFIG_DIR and CACHE_DIR. Fixes the startup toast showing the old version after an update.

  • Bug Fixes
    • invalidatePackage now removes oh-my-opencode from USER_CONFIG_DIR/node_modules and CACHE_DIR/node_modules.
    • Prevents getCachedVersion from reading a stale plugin via import.meta.url traversal.

Written for commit f67b605. Summary will update on new commits.

Fix code-yeongyu#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.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 4, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

@SeeYouCowboi
Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Mar 4, 2026
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Simple and safe expansion of the cache invalidation logic to include the CACHE_DIR, fixing the reported stale plugin issue with no risk of regression.

@acamq
Copy link
Copy Markdown
Collaborator

acamq commented Mar 7, 2026

Thank you!

@acamq acamq merged commit ab5a713 into code-yeongyu:dev Mar 7, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Startup toast shows stale version after npm update — plugin cache in CACHE_DIR not invalidated

2 participants