Visitar URL original
injectWorkspacePackages: true skips changed injected dependency manifests during optimistic install (12.14.0) · Issue #17007 · pnpm/pnpm · GitHub
Skip to content

injectWorkspacePackages: true skips changed injected dependency manifests during optimistic install (12.14.0) #17007

Closed

Description

@baymer

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

12.14.0

Which area(s) of pnpm are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue or a replay of the bug

No response

Reproduction steps

With pnpm 12.14.0 on PATH, save the following as repro.sh and run sh repro.sh normal. Alternatively set PNPM_BIN to the executable for that version. The script creates an isolated temporary directory and requires Node.js.

#!/bin/sh
set -eu
PNPM_BIN=${PNPM_BIN:-pnpm}
OPERATION=${1:-normal}
repro_dir=$(mktemp -d)
cd "$repro_dir"
mkdir app lib
printf '{"name":"root","private":true}\n' > package.json
cat > pnpm-workspace.yaml <<'YAML'
packages: [app, lib]
sharedWorkspaceLockfile: false
injectWorkspacePackages: true
dedupeInjectedDeps: false
registry: https://registry.npmjs.org/
YAML
printf '{"name":"app","private":true,"dependencies":{"lib":"workspace:*"}}\n' > app/package.json
printf '{"name":"lib","version":"1.0.0","main":"index.cjs","dependencies":{"is-number":"6.0.0"}}\n' > lib/package.json
printf "module.exports = require('is-number/package.json').version\n" > lib/index.cjs
"$PNPM_BIN" --version
"$PNPM_BIN" install --no-frozen-lockfile --ignore-scripts
cp app/pnpm-lock.yaml before.yaml
node -e 'const fs=require("node:fs");const p="lib/package.json";const j=JSON.parse(fs.readFileSync(p));j.dependencies["is-number"]="7.0.0";fs.writeFileSync(p,JSON.stringify(j))'
if [ "$OPERATION" = frozen ]; then
  "$PNPM_BIN" --filter app install --frozen-lockfile --ignore-scripts
else
  "$PNPM_BIN" --filter app install --no-frozen-lockfile --ignore-scripts
fi
if cmp -s before.yaml app/pnpm-lock.yaml; then
  echo 'consumer lockfile unchanged'
else
  echo 'consumer lockfile updated'
fi
printf 'dependency actually loaded by injected lib: '
node -p "require('./app/node_modules/lib')"
echo "Reproduction directory: $repro_dir"
if [ "$OPERATION" = normal ]; then
  "$PNPM_BIN" --filter app install --frozen-lockfile --ignore-scripts
fi

The only change is lib/package.json: is-number 6.0.0 -> 7.0.0. Neither lib's version nor app's manifest changes. dedupeInjectedDeps: false ensures lib is actually injected.

Describe the Bug

With sharedWorkspaceLockfile: false, injectWorkspacePackages: true, and existing node_modules, changing an injected package's dependency does not invalidate the consumer install. Normal non-frozen install and --lockfile-only return exit 0 without updating app/pnpm-lock.yaml, and the injected lib still loads is-number 6.0.0.

The subsequent --frozen-lockfile correctly rejects that same lockfile with ERR_PNPM_OUTDATED_LOCKFILE: local dependency "lib" at "../lib" is outdated. Thus a successful non-frozen install leaves a state pnpm itself considers invalid.

Controls tested

Variant Result on 12.14.0
Default optimistic install, existing node_modules stale lockfile and is-number 6.0.0
--filter app install --lockfile-only --no-frozen-lockfile also stale
Unfiltered install --no-frozen-lockfile at workspace root lib lockfile updates; app lockfile stays stale
Delete node_modules before non-frozen install app lockfile updates; lib loads 7.0.0
optimisticRepeatInstall: false app lockfile updates; lib loads 7.0.0
Replace global injection with app dependenciesMeta.lib.injected: true app lockfile updates; lib loads 7.0.0
Change app lib specifier to file:../lib app lockfile updates; lib loads 7.0.0
Same non-frozen global-injection repro on 11.28.6 app lockfile updates; lib loads 7.0.0

These controls suggest an optimistic-repeat-install invalidation gap specific to global injectWorkspacePackages. Related background: #7209 / #15356. Reproduced on latest npm release 12.14.0 and compared with latest 11.x 11.28.6, on macOS Darwin 25.6.0 arm64.

Expected Behavior

A non-frozen install should re-resolve the changed injected package, update app/pnpm-lock.yaml to is-number 7.0.0, and install 7.0.0 for lib. --lockfile-only should also update the consumer lockfile. A subsequent frozen install should then succeed.

Which Node.js version are you using?

v26.2.0

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

No response

Contributing a fix

  • I am working on a fix

Activity

  1. added theissue type on Oct 16, 2026
  2. zkochan commented on Oct 17, 2026

    @zkochan
    Member

    #17025 fixes this. With per-project lockfiles, the repeat-install check now reads which dependencies are injected from the consumer's lockfile. Before, it read them from the manifests, and a per-project install only sees its own manifest. It covers the whole issue: filtered, unfiltered, and --lockfile-only installs.


    Written by an agent (Claude Code, claude-opus-5-5).

  3. added a commit that references this issue on Oct 17, 2026
    3c4f1bf
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

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions