Skip to content

Commit 0dfc24e

Browse files
fix: handle non-semver VERSION in update check (#44)
When running via bun run dev, OPENCODE_VERSION is undefined so VERSION falls back to "local". getReleaseType would crash on semver.major("local"), silently killing the update prompt. Now skips semver comparison for local or non-semver versions and always notifies instead.
1 parent 19777d8 commit 0dfc24e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

packages/opencode/src/cli/upgrade.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Bus } from "@/bus"
22
import { Config } from "@/config/config"
33
import { Flag } from "@/flag/flag"
44
import { Installation } from "@/installation"
5+
import semver from "semver"
56

67
export async function upgrade() {
78
const config = await Config.getGlobal()
@@ -17,6 +18,11 @@ export async function upgrade() {
1718
if (Installation.VERSION === latest) return
1819
if (config.autoupdate === false || Flag.OPENCODE_DISABLE_AUTOUPDATE) return
1920

21+
if (Installation.isLocal() || !semver.valid(Installation.VERSION)) {
22+
await Bus.publish(Installation.Event.UpdateAvailable, { version: latest })
23+
return
24+
}
25+
2026
const kind = Installation.getReleaseType(Installation.VERSION, latest)
2127

2228
if (config.autoupdate === "notify" || kind !== "patch") {

0 commit comments

Comments
 (0)