Skip to content

Pass a Package-Scoped --allow-scripts on the Agent Installers' npm Installs #4264

Closed

Description

@ptr727

Symptom

On a Windows host with npm 11.20.0, the --agent-setup agent-tools step upgraded opencode through npm and reported it as done. npm, however, skipped the package's install script:

opencode: at 2.3.0, installed through npm, running: npm install -g @opencode/cli@latest

changed 3 packages in 12s
npm warn install-scripts 1 package has install scripts not yet covered by allowScripts:
npm warn install-scripts   @opencode/[email protected] (postinstall: node ./postinstall.mjs)
npm warn install-scripts
npm warn install-scripts Run `npm install -g --allow-scripts=@opencode/cli` to allow these scripts once, or `npm config set allow-scripts=@opencode/cli --location=user` to allow them for all global installs.

The installer passes over the warning in silence, so the step reads as a clean upgrade while the package's postinstall never ran. opencode --version still answers afterwards, so whether the skipped script matters for opencode 2.3.0 is unverified. Either way the installer should not leave it to the reader to notice.

npm's suggested one-off command does not work as printed

The "allow once" command npm prints names no package. Run as printed, npm install -g with no package spec installs the current directory, so from a home directory it fails:

npm warn install-scripts .npmrc allow-scripts setting is being ignored because --allow-scripts was passed on the command line
npm error code ENOENT
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '<home>\package.json'

The flag itself is accepted. The one-off form that works names the package too:

npm install -g --allow-scripts=@opencode/cli @opencode/cli@latest

The persistent form npm prints, npm config set allow-scripts=@opencode/cli --location=user, works as printed. After it runs, npm config get allow-scripts --location=user returns @opencode/cli.

Where it lives

Every npm install or upgrade the agent installers run, on both platforms:

  • host-setup/windows/install-agents.ps1 Get-PackageStep, the upgrade arguments @('install', '-g', "$name@latest").
  • host-setup/windows/install-agents.ps1 opencode's managed install (Source and the Invoke-Step call near line 800), npm install -g @opencode/cli.
  • host-setup/linux/install-agents.sh package_step, the upgrade command ("$manager" install -g "${pkg:-$recorded}@latest"), and any npm install path on Linux.

The claude and codex npm packages go through the same steps, so any install script they carry is skipped the same way.

Proposed fix

The installer already trusts the recorded package by name (Get-NpmPackage / npm_package), so the narrowest fix is to scope the allowance to exactly that package on each npm install step it runs: npm install -g --allow-scripts=<recorded> <recorded>@latest. That allows the one package's scripts for that one run and writes no user config. Open points for the fix:

  • Confirm how an npm older than the release that introduced allowScripts treats --allow-scripts. If it is not harmless, gate the flag on the npm version.
  • Decide whether the installer should also surface an install-scripts warning when one still appears, rather than reporting the step as clean.
  • Cover the new argument in Tests/test_install_agents.py, whose expected command strings (npm install -g @openai/codex@latest and the rest) change with it.
  • --dry-run and the printed "run: ..." remedies should show the same full command, so a reader copying one gets a command that works.

Activity

  1. added
    bug
    on Nov 18, 2026
  2. added a commit that references this issue on Nov 18, 2026
    c76e275
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions