You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
opencode template: sandbox ships opencode-ai without its postinstalled binary — "postinstall script was not run" on first run (v1.18.12) #395
A freshly created opencode sandbox fails on first run because the bundled opencode-ai npm package is present but its postinstall step never ran, so the platform binary was never fetched. Launching the agent errors with:
Error: opencode-ai's postinstall script was not run.
This occurs when using --ignore-scripts during installation, or when using a
package manager like pnpm that does not run postinstall scripts by default.
To fix this, run the postinstall script manually:
cd node_modules/opencode-ai && node postinstall.mjs
opencode has required this postinstall step to fetch its binary since v1.15.1 (see anomalyco/opencode#27906). The sandbox-templates:opencode-docker image appears to install opencode-ai at build time in a way that skips lifecycle scripts, so the binary is missing in the shipped image.
Evidence it is a build-time script-skip, not a runtime setting
Inside the running sandbox:
$ npm ls -g opencode-ai
/usr/local/share/npm-global/lib
`-- [email protected]
$ npm config get ignore-scripts
false
So ignore-scripts is false at runtime — the package is installed but its postinstall never executed, which points to the image being built with a scripts-skipping installer (e.g. npm ci --ignore-scripts, or pnpm/bun which skip postinstall by default).
Every new opencode sandbox created from the current image is broken on first launch until the user manually runs node postinstall.mjs inside the sandbox.
Requested fix
Build the opencode-docker template so opencode-ai's postinstall runs (don't pass --ignore-scripts; if using pnpm/bun, run the postinstall explicitly or allowlist it), so the platform binary is present in the shipped image.
Workaround (for others hitting this)
Inside the sandbox:
cd "$(npm root -g)/opencode-ai" && node postinstall.mjs
Additional context — reproduced by more than one macOS user, and a note on severity + the reliable workaround.
Severity: the sandbox is created but cannot be launched.sbx run <sandbox> fails at the agent-launch step (opencode's postinstall guard fires and exits), so the sandbox exists but never becomes usable via run. Importantly, you cannot fix it from a run — sbx run re-launches opencode each time and re-hits the same error.
Reliable workaround (confirmed): apply the fix with sbx exec, which runs a command in the sandbox without launching the agent:
sbx ls # find the created sandbox name
sbx exec<sandbox-name> -- sh -c 'cd "$(npm root -g)/opencode-ai" && node postinstall.mjs'
sbx exec<sandbox-name> -- opencode --version # confirms the binary now resolves
After that, sbx run <sandbox-name> attaches normally. (If sbx exec reports the sandbox isn't running, sbx start <sandbox-name> first.)
Confirmed on [email protected], sbx v0.37.1, macOS/Apple Silicon: sbx run kept failing with the postinstall error, while sbx exec … -- opencode --version succeeded and got the sandbox past it.
Restating the root cause for triage: on first launch, the shipped opencode-docker image has the opencode-ai npm package present but its postinstalled platform binary missing (npm config get ignore-scripts is false at runtime, so it is a build-time lifecycle-script skip, not a runtime setting). opencode has required this postinstall to fetch its binary since v1.15.1 (anomalyco/opencode#27906). Building the image so opencode-ai's postinstall runs (or running it explicitly at build) would ship a working binary and remove the need for the manual step above.
Hi @wz-gsa, thanks for the detailed report and workaround! This is fixed from v0.39.0: the opencode template now runs the opencode-ai postinstall step when the image is built, and the build checks opencode --version. Please recreate the sandbox to pick up the current image, and reopen this if it still fails.
Activity
docs: add KNOWN_FAILURE_MODES entry for opencode postinstall gap in s…
wz-gsa commentedon Aug 4, 2026
Additional context — reproduced by more than one macOS user, and a note on severity + the reliable workaround.
Severity: the sandbox is created but cannot be launched.
sbx run <sandbox>fails at the agent-launch step (opencode's postinstall guard fires and exits), so the sandbox exists but never becomes usable viarun. Importantly, you cannot fix it from arun—sbx runre-launches opencode each time and re-hits the same error.Reliable workaround (confirmed): apply the fix with
sbx exec, which runs a command in the sandbox without launching the agent:After that,
sbx run <sandbox-name>attaches normally. (Ifsbx execreports the sandbox isn't running,sbx start <sandbox-name>first.)Confirmed on
[email protected], sbx v0.37.1, macOS/Apple Silicon:sbx runkept failing with the postinstall error, whilesbx exec … -- opencode --versionsucceeded and got the sandbox past it.Restating the root cause for triage: on first launch, the shipped
opencode-dockerimage has theopencode-ainpm package present but its postinstalled platform binary missing (npm config get ignore-scriptsisfalseat runtime, so it is a build-time lifecycle-script skip, not a runtime setting). opencode has required this postinstall to fetch its binary since v1.15.1 (anomalyco/opencode#27906). Building the image soopencode-ai's postinstall runs (or running it explicitly at build) would ship a working binary and remove the need for the manual step above.slowcommit commentedon Aug 4, 2026
Thanks for the workaround. The same problem occurs on Windows as well.
ericcurtin commentedon Oct 1, 2026
Hi @wz-gsa, thanks for the detailed report and workaround! This is fixed from v0.39.0: the opencode template now runs the
opencode-aipostinstall step when the image is built, and the build checksopencode --version. Please recreate the sandbox to pick up the current image, and reopen this if it still fails.