fix(auto-updater): handle bun.lockb and add workspace validation

- Support binary bun.lockb format by deleting entire file (cannot parse)
- Add workspace check: verify package.json exists before bun install
- Quote paths in error messages for Windows/paths with spaces
This commit is contained in:
acamq
2026-03-08 09:15:13 -06:00
parent f89cc969ec
commit c4112f80db
3 changed files with 45 additions and 14 deletions
+10 -1
View File
@@ -1,3 +1,4 @@
import { existsSync } from "node:fs"
import { getOpenCodeCacheDir } from "../../shared/data-path"
import { log } from "../../shared/logger"
import { spawnWithWindowsHide } from "../../shared/spawn-with-windows-hide"
@@ -18,6 +19,14 @@ export async function runBunInstall(): Promise<boolean> {
export async function runBunInstallWithDetails(): Promise<BunInstallResult> {
const cacheDir = getOpenCodeCacheDir()
const packageJsonPath = `${cacheDir}/package.json`
if (!existsSync(packageJsonPath)) {
return {
success: false,
error: `Workspace not initialized: ${packageJsonPath} not found. OpenCode should create this on first run.`,
}
}
try {
const proc = spawnWithWindowsHide(["bun", "install"], {
@@ -43,7 +52,7 @@ export async function runBunInstallWithDetails(): Promise<BunInstallResult> {
return {
success: false,
timedOut: true,
error: `bun install timed out after ${BUN_INSTALL_TIMEOUT_SECONDS} seconds. Try running manually: cd ${cacheDir} && bun i`,
error: `bun install timed out after ${BUN_INSTALL_TIMEOUT_SECONDS} seconds. Try running manually: cd "${cacheDir}" && bun i`,
}
}