fix: run opencode-ai postinstall script after npm install #24

Merged
jcabillot merged 1 commits from fix/opencode-postinstall into main 2026-07-13 18:17:40 -04:00
Owner

Problem

opencode --version fails during Docker build because opencode-ai's postinstall script isn't executed by npm install -g.

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.

Seen in Renovate PR #23 (bumping opencode-ai to 1.17.18): CI run #3953

Fix

Explicitly run the postinstall script after npm install -g:

npm install -g --no-fund --no-audit opencode-ai@1.17.13 n2-soul@9.0.9 && \
    cd /usr/local/lib/node_modules/opencode-ai && node postinstall.mjs && \
    npm cache clean --force

This ensures opencode --version works regardless of whether the base image's npm configuration ignores scripts.

## Problem `opencode --version` fails during Docker build because `opencode-ai`'s postinstall script isn't executed by `npm install -g`. ``` 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. ``` Seen in Renovate PR #23 (bumping opencode-ai to 1.17.18): [CI run #3953](https://scm.cabillot.eu/perso/opencode/actions/runs/3953) ## Fix Explicitly run the postinstall script after `npm install -g`: ```dockerfile npm install -g --no-fund --no-audit opencode-ai@1.17.13 n2-soul@9.0.9 && \ cd /usr/local/lib/node_modules/opencode-ai && node postinstall.mjs && \ npm cache clean --force ``` This ensures `opencode --version` works regardless of whether the base image's npm configuration ignores scripts.
opencodecabilloteu force-pushed fix/opencode-postinstall from 1722e0bfad to bc7d0580ac 2026-07-13 16:30:47 -04:00 Compare
opencodecabilloteu force-pushed fix/opencode-postinstall from bc7d0580ac to 9160870ae2 2026-07-13 16:38:09 -04:00 Compare
opencodecabilloteu force-pushed fix/opencode-postinstall from 9160870ae2 to 247e0cf00b 2026-07-13 16:38:18 -04:00 Compare
opencodecabilloteu force-pushed fix/opencode-postinstall from 247e0cf00b to 85c10f908b 2026-07-13 16:46:26 -04:00 Compare
opencodecabilloteu added 1 commit 2026-07-13 16:52:37 -04:00
fix: pass --allow-scripts to npm install for blocked postinstall
PR Checks / hadolint (pull_request) Successful in 5s
PR Checks / build-test (pull_request) Successful in 3m7s
7dc7c4a043
The node:24-trixie base image has npm configured with a restricted
allowScripts list, preventing opencode-ai's postinstall from running.
Pass --allow-scripts=opencode-ai,better-sqlite3 to npm install -g to
explicitly allow these packages to run their install scripts.

This is the npm-recommended fix as shown in the npm warning message.
opencodecabilloteu force-pushed fix/opencode-postinstall from 85c10f908b to 7dc7c4a043 2026-07-13 16:52:37 -04:00 Compare
jcabillot merged commit f72c3513d4 into main 2026-07-13 18:17:40 -04:00
jcabillot deleted branch fix/opencode-postinstall 2026-07-13 18:17:41 -04:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: perso/opencode#24