refactor: drop the speculative OPENCODE_GLOBAL_ROOT escape hatch

The workerd tmp-rooting is what the profile needs; an env override with
no consumer can return when something wants it.
This commit is contained in:
Kit Langton
2026-08-11 23:20:34 -04:00
parent 15fd792d92
commit 4b4e2c43be
+2 -3
View File
@@ -8,10 +8,9 @@ import { makeGlobalNode } from "./effect/app-node.js"
const app = "opencode"
// workerd has no home directory or XDG base dirs and only tmp is writable, so
// root every global path under one directory there. OPENCODE_GLOBAL_ROOT
// overrides the root on any runtime.
// root every global path under one directory there.
const workerd = (globalThis as { navigator?: { userAgent?: string } }).navigator?.userAgent === "Cloudflare-Workers"
const root = process.env.OPENCODE_GLOBAL_ROOT ?? (workerd ? path.join(os.tmpdir(), app) : undefined)
const root = workerd ? path.join(os.tmpdir(), app) : undefined
const data = root ? path.join(root, "data") : path.join(xdgData!, app)
const cache = root ? path.join(root, "cache") : path.join(xdgCache!, app)
const config = root ? path.join(root, "config") : path.join(xdgConfig!, app)