Skip to content

opencode template: sandbox ships opencode-ai without its postinstalled binary — "postinstall script was not run" on first run (v1.18.12) #395

Description

@wz-gsa

Summary

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.

Environment

  • macOS (Apple Silicon)
  • sbx v0.37.1
  • image: docker/sandbox-templates:opencode-docker (freshly pulled)
  • opencode-ai@1.18.12, installed at /usr/local/share/npm-global/lib

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
`-- opencode-ai@1.18.12

$ 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).

Running the postinstall manually fixes it:

$ cd "$(npm root -g)/opencode-ai" && node postinstall.mjs
$ opencode --version
1.18.12

Impact

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

Possibly related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions