Skip to content

vp migrate runs its install with --ignore-scripts on pnpm ≥ 11, which leaves an approved git dependency unbuilt, and vp install does not rebuild it #3603

In review

Description

@caglarenes

Describe the bug

runViteInstall (packages/cli/src/utils/prompts.ts) adds --ignore-scripts to the install vp migrate runs when the project uses pnpm 11 or later. The aim is to keep an unapproved build script from failing the install with ERR_PNPM_IGNORED_BUILDS. The comment says the user's own next vp install keeps pnpm's default behavior.

That does not hold for a git dependency whose files come from prepare, even when its build is approved in allowBuilds:

  1. The migration aliases vite to the core. That changes the peers of any dependency with a vite peer, so pnpm puts the git dependency into a new virtual-store directory.
  2. --ignore-scripts skips its prepare there, so its dist/ is never built.
  3. The next vp install reports "Already up to date", and pnpm's rebuild does not run a skipped prepare either (pnpm rebuild never runs a git-hosted dependency's prepare that --ignore-scripts skipped; only pnpm install --force does pnpm/pnpm#18551).
  4. Only pnpm install --force brings dist/ back. Until then the build fails to resolve the package.

We migrated four game projects that consume a shared UI library as a git dependency pinned to a commit, with its build allowed in allowBuilds. All four lost the library's dist/ this way.

pnpm already has a setting for what the flag is used for: strictDepBuilds. With --config.strict-dep-builds=false instead of --ignore-scripts, the same install exits 0. Builds that are approved (here the git dependency's prepare) still run, and the unapproved ones are skipped and listed for pnpm approve. Measured on the reproduction below, with a second git dependency added whose build (a postinstall) is not in allowBuilds:

Install after the migration edit Exit Approved git dependency's dist/ Unapproved build
pnpm install (default, strict) 1, ERR_PNPM_IGNORED_BUILDS built skipped
pnpm install --ignore-scripts (what migrate runs) 0 missing skipped
pnpm install --config.strict-dep-builds=false 0 built skipped, "Run pnpm approve"

If this direction works for you, I can send a PR that makes the auto-install pass --config.strict-dep-builds=false instead of --ignore-scripts on pnpm ≥ 11.

Reproduction

Steps below (a local git repository stands in for the library; no remote needed).

Steps to reproduce

set -eu
root=$(mktemp -d)
cd "$root"

# The library: dist/ comes from prepare, and vite is an optional peer.
mkdir lib
cd lib
cat >package.json <<'EOF'
{
  "name": "lib",
  "version": "1.0.0",
  "type": "module",
  "files": ["dist"],
  "exports": { ".": "./dist/index.js" },
  "scripts": { "prepare": "node -e \"require('fs').mkdirSync('dist',{recursive:true});require('fs').writeFileSync('dist/index.js','export default 1')\"" },
  "peerDependencies": { "vite": "*" },
  "peerDependenciesMeta": { "vite": { "optional": true } }
}
EOF
echo dist >.gitignore
git init -q && git add -A && git commit -qm init
cd ..

LIB="git+file://$root/lib#$(git -C lib rev-parse HEAD)"
mkdir app
cd app
cat >package.json <<EOF
{
  "name": "app",
  "private": true,
  "type": "module",
  "packageManager": "pnpm@12.23.0",
  "scripts": { "build": "vite build" },
  "dependencies": { "lib": "$LIB" },
  "devDependencies": { "vite": "8.3.8" }
}
EOF
cat >pnpm-workspace.yaml <<EOF
allowBuilds:
  'lib@$LIB': true
EOF
echo 'export default {};' >vite.config.ts
echo node_modules >.gitignore
git init -q && git add -A && git commit -qm init

check() { if [ -f node_modules/lib/dist/index.js ]; then echo "lib dist: present"; else echo "lib dist: MISSING"; fi; }

pnpm install >/dev/null
check                         # present

git add -A && git commit -qm installed
vp migrate --no-interactive --no-agent --no-editor --no-hooks
check                         # MISSING

vp install
check                         # still MISSING

pnpm install --force >/dev/null
check                         # present

System Info

# The global CLI is not installed here, so there is no `vp env current`.
$ vp --version
vp v1.8.0

Local vite-plus:
  vite-plus  v1.8.0

Node 26.13.1, pnpm 12.23.0, Windows 11

Used Package Manager

pnpm

Logs

The steps above, run as written:

lib dist: present
$ vp migrate --no-interactive --no-agent --no-editor --no-hooks
● Formatting code...
● Code formatted
◇ Migrated . to Vite+ 1.8.0
• Node 26.13.1  pnpm 12.23.0
✓ Dependencies installed in 4.9s
lib dist: MISSING
$ vp install
Already up to date
Done in 8ms using pnpm v12.23.0
lib dist: MISSING
$ pnpm install --force
lib dist: present

AI disclosure: I found and wrote this with Claude Code (model: Claude Opus 5.5, claude-opus-5-5; its reasoning effort level is not shown to me). I ran the steps above with vite-plus 1.8.0 and pnpm 12.23.0.

Activity

  1. added theissue type on Nov 29, 2026
  2. voidzero-bot commented on Nov 29, 2026

    @voidzero-bot
    Contributor
    • Reproduced: Yes — followed the issue's exact reproduction on the current main checkout (pnpm 12.23.0): lib dist: MISSING after vp migrate, still missing after vp install, restored only by pnpm install --force.
    • Exploration: Yes — View branch
    • Unit Test: Yes — packages/cli/src/utils/__tests__/run-vite-install.spec.ts (new assertion fails without the fix, passes with it)
    • Priority: Priority P2: Has Workaround. The bug breaks the documented post-migration flow (run vp install, then vp build), but only for pnpm ≥ 11 projects with a git dependency whose dist/ comes from an approved prepare script, and pnpm install --force reliably recovers the state.

    runViteInstall (packages/cli/src/utils/prompts.ts) adds --ignore-scripts to every auto-install on pnpm ≥ 11 unless the caller opts into detectIgnoredBuilds, and neither vp migrate install opts in. That flag skips all lifecycle scripts — including builds the user already approved via allowBuilds. It is normally harmless because a no-op reinstall re-runs nothing, but migration adds the vite@* → @voidzero-dev/vite-plus-core override, which gives a vite-peering git dependency a new virtual-store directory; pnpm re-fetches it there with prepare skipped, and no later vp install, pnpm rebuild, or vp pm approve-builds can re-run a skipped prepare (pnpm/pnpm#18551).

    I found a potential fix for this issue. On the branch, runViteInstall passes --config.strict-dep-builds=false (through vp install's -- pass-through slot) instead of --ignore-scripts: auto-installs still exit 0, approved builds like the git dependency's prepare run, and unapproved builds are skipped but remain recoverable via pnpm approve-builds. The reproduction keeps dist/ present through migrate and the follow-up vp install, and the full unit suite plus the migration CLI snapshots pass.

    Full Triage Report

    Triage Report — Issue #3603

    Issue summary

    vp migrate auto-installs with --ignore-scripts on pnpm ≥ 11
    (shouldIgnoreScriptsForAutoInstall in packages/cli/src/utils/prompts.ts,
    called from runViteInstall; both install call sites in
    packages/cli/src/migration/bin.ts leave detectIgnoredBuilds off). The intent
    is to avoid pnpm ≥ 11's ERR_PNPM_IGNORED_BUILDS hard failure while the user
    has not yet approved build scripts.

    For a git dependency whose dist/ is produced by its prepare script, the
    aliasing of vite to @voidzero-dev/vite-plus-core changes the dependency's
    peer set, so pnpm places the git dependency in a new virtual-store directory
    and re-fetches/relinks it. Because --ignore-scripts skips prepare there,
    the dependency is installed without its dist/. A later vp install reports
    "Already up to date" (nothing changed in the lockfile) and pnpm's rebuild
    does not re-run a skipped prepare, so only pnpm install --force recovers.

    Expected: after migration (with the git dependency's build approved in
    allowBuilds), node_modules/lib/dist/index.js exists and the project builds.
    Actual: dist/ is missing after vp migrate, still missing after vp install,
    and only pnpm install --force restores it.

    Environment

    • Vite+: current main checkout (local build v1.8.0, reported by vp --version as vp v1.8.0 / vite-plus v1.8.0)
    • Node.js: v24.22.3 on the runner (migrate log shows Node 26.13.1, the version vp resolves for the pinned packageManager)
    • pnpm: v12.11.2 on PATH; reproduction project pins pnpm@12.23.0 (both ≥ 11, so --ignore-scripts applies)
    • OS: Ubuntu x64 (issue reported on Windows 11; reproduction is OS-agnostic)
    • Reproduction path: /tmp/vite-plus-triage/gh-3603/repro (script: repro.sh, log: repro.log)

    Commands attempted and results

    Reproduction follows the issue's steps exactly, with vp migrate wrapped by the
    local npm registry (packages/tools/src/local-npm-registry.ts --pack) so the
    project installs the checkout's own vite-plus build:

    Step Result
    pnpm install (before migrate) exit 0 — lib dist: present
    vp migrate --no-interactive --no-agent --no-editor --no-hooks exit 0 — "Dependencies installed", lib dist: MISSING
    vp install "Already up to date / Done in 3ms using pnpm v12.23.0" — lib dist: MISSING
    pnpm install --force lib dist: present again (see note below)

    Note on the last step: the final pnpm install --force restored
    node_modules/lib/dist/index.js (the reported recovery), though it then exited 1
    with ERR_PNPM_TARBALL_URL_MISMATCH on the @voidzero-dev/vite-plus-core
    entry. That error is an artifact of the triage local registry only: the lockfile
    records the registry bridge URL with the port of the first server run, and a
    newly started registry server gets a different port. It does not affect the
    reproduction of the reported behavior, which is fully visible in the three
    preceding steps.

    Control case

    The same project state before migration keeps lib dist: present under plain
    pnpm install (first row above), i.e. the allowBuilds approval for the git
    dependency works and the loss of dist/ only occurs after the migrate
    auto-install. This rules out a misconfigured reproduction (wrong allowBuilds
    key, missing prepare, etc.) as the cause.

    Result

    Reproduced on the current checkout (triagebot/fix-3603): after
    vp migrate, the approved git dependency's prepare output (dist/) is
    missing, vp install does not restore it, and pnpm install --force does.

    Issue classification: Bug.


    Diagnosis

    Affected code (all on current main)

    Location Role
    packages/cli/src/utils/prompts.ts:30-46 shouldIgnoreScriptsForAutoInstall — returns true for pnpm ≥ 11
    packages/cli/src/utils/prompts.ts:132-215 (runViteInstall) pushes --ignore-scripts onto the install args when detectIgnoredBuilds is not set
    packages/cli/src/migration/bin.ts:852 and :1033 both vp migrate installs call runViteInstall without detectIgnoredBuilds, with the detected pnpm version
    packages/cli/src/utils/command.ts:28-38 (getVpCommand) the install runs as vite-plus/bin install --ignore-scripts
    crates/vp_pm_cli/src/resolution/commands/install.rs:111-131 vp install maps its own --ignore-scripts flag and otherwise forwards pass_through_args verbatim to pnpm install

    Root cause

    runViteInstall unconditionally adds --ignore-scripts on pnpm ≥ 11 for every
    auto-install that does not opt into detectIgnoredBuilds — and neither migrate
    install opts in. --ignore-scripts disables all lifecycle scripts, including
    prepare of git dependencies whose build the user already approved via
    allowBuilds / onlyBuiltDependencies.

    This is normally harmless because a no-op reinstall doesn't re-run anything.
    Migration is the exception: it writes

    # pnpm-workspace.yaml (added by migrate)
    overrides:
      vite@*: "catalog:"
    catalog:
      vite: npm:@voidzero-dev/vite-plus-core@8.3.8001

    which changes the resolved peers of every dependency with a vite peer. For a
    git dependency that means a new virtual-store directory. Observed in the
    reproduction (repro2, state inspected between migrate and --force):

    node_modules/.pnpm/lib@git+...79aee793bb1df25fb22298f57c3ab61_53f45121ceee348a37522afeb6707a52 -> dist: present   (initial install)
    node_modules/.pnpm/lib@git+...79aee793bb1df25fb22298f57c3ab61_936c7752b5a3a37e10bf73fbc3017a61 -> dist: MISSING  (created by migrate's install)
    

    The two entries differ only in pnpm's peer-set hash suffix; node_modules/lib
    symlinks to the new, dist-less entry. Because --ignore-scripts was in
    effect, pnpm skipped the git dependency's prepare when populating the new
    directory.

    Why nothing recovers it: the migrate install still exits 0 and produces a
    consistent lockfile, so the next vp install → pnpm install is a no-op
    ("Already up to date"), and pnpm's rebuild does not re-run a prepare that
    was skipped (pnpm/pnpm#18551). Only pnpm install --force refetches the git
    dependency and runs prepare, which restores dist/ (observed).

    Edge cases and caveats for the fix

    1. vp install's argument parser rejects the flag form. Passing
      --config.strict-dep-builds=false directly fails with clap's
      error: Unexpected argument '--config.strict-dep-builds' (exit 2), which
      made the migrate install fail outright in the first experiment. The flag
      must go through the pass-through slot:
      installArgs.push('--', '--config.strict-dep-builds=false') — verified to
      reach pnpm as pnpm install --config.strict-dep-builds=false and exit 0.
    2. Version gating: strictDepBuilds exists in pnpm ≥ 10.7 and became the
      default failure mode in pnpm 11. The workaround is only applied for
      pnpm ≥ 11 today, so the replacement stays inside the same gate.
    3. Other runViteInstall callers: packages/cli/src/create/bin.ts
      shares the same helper; all its call sites use detectIgnoredBuilds, so
      they are unaffected by the change.
    4. vp install alone cannot fix the after-the-fact state: once the new
      virtual-store entry exists without dist/, only pnpm install --force
      refetches it. Fixing the flag used by the migrate auto-install is the
      correct layer.

    Regression evidence

    Introduced by commit b92a1afc0 (2026-05-08,
    fix(cli): auto-pass --ignore-scripts when pnpm >=11 in migrate/create,
    PR #1533), which added shouldIgnoreScriptsForAutoInstall and the
    installArgs.push('--ignore-scripts') branch.

    Confidence

    high — the failing logic is proven by code inspection (flag added on pnpm
    ≥ 11 for both migrate installs, forwarded verbatim to pnpm install), the
    missing-dist state is observed in the new virtual-store directory, and
    swapping the flag for --config.strict-dep-builds=false makes the approved
    prepare run again while keeping the unapproved build skipped.


    Verification

    Claim

    Observed (reproduced): after vp migrate on pnpm ≥ 11, a git dependency
    whose build is approved in allowBuilds ends up without its prepare-built
    dist/. The follow-up vp install is a no-op ("Already up to date"),
    vp pm approve-builds reports nothing pending, and only pnpm install --force
    recovers.

    Expected (reporter): a migration whose git dependency build is approved via
    allowBuilds leaves the project buildable; the documented post-migration
    install is sufficient.

    Verdict: bug (high confidence)

    1. Documented post-migration flow is broken. docs/guide/migrate.md
      ("After running the migration: Run vp install … Run vp build") promises
      that a follow-up install completes dependency installation and the build
      works. Observed: the follow-up vp install is a no-op and vp build cannot
      resolve the library until pnpm install --force.

    2. The workaround's own comment states a false assumption.
      packages/cli/src/utils/prompts.ts:30-34: "the user's own subsequent
      vp install keeps default pnpm behavior." For a git dependency re-fetched
      into a new virtual-store directory by the migration's vite@* →
      @voidzero-dev/vite-plus-core override, the subsequent install is a no-op
      and never re-runs prepare.

    3. Maintainers already treat "unrecoverable gated builds" as a defect.
      packages/cli/src/utils/prompts.ts (added with detectIgnoredBuilds in
      PR feat(create): approve dependency build scripts blocked by the package manager #1828): "--ignore-scripts … also makes the gated builds unrecoverable
      (approve-builds then reports nothing pending)." vp create was changed to
      surface/approve builds because of exactly this problem; vp migrate never
      adopted the same treatment.

    4. Documented product intent: no half-built projects.
      docs/guide/create.md:108-112: create "surfaces gated builds after
      installing instead of leaving the project in a half-built state."
      Migration leaves an approved build half-built.

    5. Vite+'s own recovery path cannot help. Verified on the reproduction:
      vp pm approve-builds lib →
      [WARN] The following packages are not awaiting approval: lib, and
      dist/ stays missing. pnpm rebuild does not re-run a skipped prepare
      either (pnpm rebuild never runs a git-hosted dependency's prepare that --ignore-scripts skipped; only pnpm install --force does pnpm/pnpm#18551).

    6. No test or doc asserts the observed behavior. The only coverage asserts
      the --ignore-scripts workaround itself (install succeeds, exit 0); nothing
      asserts that approved builds may be lost. PR fix(cli): auto-pass --ignore-scripts when pnpm >=11 in migrate/create #1533's stated goal was only to
      stop unapproved build scripts from failing auto-installs — not to suppress
      builds the user already approved via allowBuilds.

    Ownership: pnpm's --ignore-scripts semantics and its rebuild/prepare
    limitation are upstream (pnpm/pnpm#18551), but the defect is Vite+'s: the
    choice to pass --ignore-scripts during migrate's install, and the
    vite@* → core override that triggers the re-fetch, are both Vite+ decisions.


    Fix

    Changed files

    File Change
    packages/cli/src/utils/prompts.ts shouldIgnoreScriptsForAutoInstall renamed to shouldRelaxStrictDepBuildsForAutoInstall; runViteInstall now passes -- --config.strict-dep-builds=false (via vp install's pass-through slot) instead of --ignore-scripts for pnpm ≥ 11 auto-installs; comments updated
    packages/cli/src/create/bin.ts comment updated to describe the relaxation instead of --ignore-scripts (no behavior change)
    packages/cli/src/utils/__tests__/run-vite-install.spec.ts regression test updated; new test for an explicit caller --ignore-scripts
    packages/cli/src/utils/__tests__/prompts.spec.ts renamed with the function

    Rationale

    --config.strict-dep-builds=false achieves the workaround's original goal
    (auto-installs do not hard-fail on pnpm ≥ 11's ERR_PNPM_IGNORED_BUILDS) while
    still running builds the user approved via allowBuilds / onlyBuiltDependencies
    — in particular a git dependency's prepare. Unapproved builds are skipped and
    remain recoverable through pnpm approve-builds. The flag must go through
    vp install's pass-through slot (-- <arg>) because vp install's argument
    parser rejects --config.<key> as a first-class flag. The existing
    detectIgnoredBuilds path (used by all vp create installs) is unchanged: it
    keeps the relaxation off so pnpm records gated builds.

    Regression test

    packages/cli/src/utils/__tests__/run-vite-install.spec.ts:
    "relaxes strict-dep-builds (and reports no pendingBuilds) when detection is off"
    asserts the spawned install receives -- --config.strict-dep-builds=false.
    Confirmed it fails without the fix (received install --ignore-scripts)
    and passes with it. "keeps an explicit --ignore-scripts from the caller"
    guards the existing escape hatch.

    Validation

    Check Result
    Rebuild (pnpm -F vite-plus build-ts) ok
    Original issue reproduction (vp migrate → vp install, pnpm 12.23.0) fixed: lib dist: present after migrate and after vp install (was MISSING)
    Control case (second git dep whose postinstall is unapproved) its build still skipped (stamp: MISSING), install exits 0, approved lib built
    Regression test without fix fails; with fix passes
    Focused tests (install-failure-guard, run-vite-install, prompts specs) 24/24 pass
    pnpm test:unit (vp test) 129 files, 3764 passed, 1 skipped
    just snapshot-test migration 350/350 pass, no snapshot diffs
    vp check formatting pass; the 105 lint/type errors are pre-existing on a clean tree (identical count with changes stashed) and none touch the changed files
    git status --short --untracked-files=all only the four intended source/test files

    Skipped: just check / just test / just lint (Rust workspace) — the change
    is TypeScript-only and no Rust source changed; full pnpm bootstrap-cli && pnpm test — covered by the unit suite plus the migration snapshot filter that
    exercises vp migrate end-to-end against the rebuilt packages/cli/dist.

    Alternatives considered

    • Adding a first class --config/--no-strict-dep-builds flag to vp install
      in crates/vp_pm_cli — larger surface change across five package managers;
      the pass-through slot already delivers the flag verbatim to pnpm.
    • Making vp migrate adopt the detectIgnoredBuilds + approve-builds flow
      (as vp create does) — better UX long-term but a larger behavioral change
      (interactive prompts inside migrate); out of scope for a minimal fix.
    • A recovery pass in vp install (detect git deps missing their prepare
      output) — pnpm's own rebuild cannot re-run a skipped prepare
      (pnpm rebuild never runs a git-hosted dependency's prepare that --ignore-scripts skipped; only pnpm install --force does pnpm/pnpm#18551), so this would require --force-like refetches; fixing the
      flag at the source is correct.

    This report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.

    I've opened a pull request with this fix: #3605

  3. added
    - P2: has workaround
    on Nov 29, 2026
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

    - P2: has workaroundtriage: fix verified

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Target date

    None yet

    Start date

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions