Repository navigation
Conversation
Backport pacote 22's ignoreScripts guard so installing a Git dependency does not spawn npm to run lifecycle scripts. OpenCode already passes ignoreScripts, and in bundled builds the spawned npm path points into Bun's virtual filesystem.
There was a problem hiding this comment.
Looks good. I ran the #49704 reproduction from source. On the base, a git+file:// plugin with a build script fails with git dep preparation failed. With this PR it installs. The new test fails on the base and passes here, and the rest of npm.test.ts and tsc -b for packages/core pass.
The new guard is the same as the one in upstream pacote's main lib/git.js, in the same place. Skipping preparation matches how OpenCode already installs packages: both Arborist calls in packages/util/src/npm.ts set ignoreScripts: true. So Git plugins now install like registry ones, without running their scripts. Before, they could not install at all. Because the nested npm spawn no longer happens, this also fixes the Windows .cmd spawn failure reported separately.
Public API: unchanged; only the vendored pacote patch and a test change.
No blocking concerns.
Fixes #59504
|
Measured what honouring With
So the guard removes the error but ships the dependency unbuilt. For a plugin with The preparation does not fail because building is unwanted — it fails because the child process is wrong. pacote spawns Suggestion: keep this guard as the fallback for machines with no npm, but try the preparation first with a resolved |
|
@JoshRob297 is right, and the measurement settles it. Skipping preparation makes the install succeed while leaving the package unbuilt, so a plugin with The preparation step is not the problem; the child process is. #62817 fixes that by resolving a real |
Issue for this PR
Closes #49704
Type of change
What does this PR do?
OpenCode installs Git plugins with
ignoreScripts: true, but pacote 21.5.1 still runs its Git preparation step for packages that declarebuild/prepare/install/postinstallscripts. That step spawnsnpm installinside the clone.In a compiled OpenCode binary the npm path resolves into Bun's bundled filesystem, so the spawn re-executes
opencodewith$bunfs/bin/npm-cli.js install .... OpenCode prints help and exits, and the install fails withgit dep preparation failed.This backports pacote 22's guard into the existing pacote patch: skip Git preparation when
ignoreScriptsis set.How did you verify your code works?
Added
skips Git package preparation when scripts are ignoredtopackages/core/test/npm.test.ts. The test fails before the patch withgit dep preparation failedand passes after it.I also ran
bun dev plugin add github:psh4607-works/opencode-agent-sidebar#v0.2.5; installation succeeds, and the TUI renders the plugin'sAgentssection. Targeted test and@opencode/core/@opencode/utiltypecheck pass.Checklist
Added by the opencode bot (AI-generated).
Fixes #59504