From 28a0dd06c7ae981bbe86fad5130add7c2d40d867 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Wed, 28 Jan 2026 15:54:17 +0900 Subject: [PATCH] fix: resolve version detection for npm global installations (#1194) When oh-my-opencode is installed via npm global install and run as a compiled binary, import.meta.url returns a virtual bun path ($bunfs) instead of the actual filesystem path. This caused getCachedVersion() to return null, resulting in 'unknown' version display. Add fallback using process.execPath which correctly points to the actual binary location, allowing us to walk up and find the package.json. Fixes #1182 --- src/hooks/auto-update-checker/checker.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/hooks/auto-update-checker/checker.ts b/src/hooks/auto-update-checker/checker.ts index 2d35453f..975d7383 100644 --- a/src/hooks/auto-update-checker/checker.ts +++ b/src/hooks/auto-update-checker/checker.ts @@ -170,6 +170,20 @@ export function getCachedVersion(): string | null { log("[auto-update-checker] Failed to resolve version from current directory:", err) } + // Fallback for compiled binaries (npm global install) + // process.execPath points to the actual binary location + try { + const execDir = path.dirname(fs.realpathSync(process.execPath)) + const pkgPath = findPackageJsonUp(execDir) + if (pkgPath) { + const content = fs.readFileSync(pkgPath, "utf-8") + const pkg = JSON.parse(content) as PackageJson + if (pkg.version) return pkg.version + } + } catch (err) { + log("[auto-update-checker] Failed to resolve version from execPath:", err) + } + return null }