Skip to content

fix(env-installer): suppress 'Installing config dependencies...' on no-op installs#11766

Merged
zkochan merged 4 commits into
mainfrom
install-config-output
May 20, 2026
Merged

fix(env-installer): suppress 'Installing config dependencies...' on no-op installs#11766
zkochan merged 4 commits into
mainfrom
install-config-output

Conversation

@zkochan

@zkochan zkochan commented May 20, 2026

Copy link
Copy Markdown
Member

Summary

The default reporter printed Installing config dependencies... every time pnpm install ran with config dependencies, even when everything was already cached and correctly symlinked.

In installing/env-installer/src/installConfigDeps.ts the installing-config-deps 'started' event was emitted unconditionally inside the per-dep Promise.all, before any of the existence/symlink checks. The companion 'done' event was already gated on installedConfigDeps.length, so an idempotent run printed Installing... with no follow-up Installed: line — the worst of both worlds.

Fix

  • Introduce a reportStarted() closure that emits the started event at most once per installConfigDeps call.
  • Remove the unconditional emission from the per-dep loop.
  • Call reportStarted() only at the sites that do real fs work:
    • orphan parent rimraf,
    • parent fetch + import,
    • parent re-symlink (after the parentSymlinkAlreadyCorrect short-circuit),
    • orphan subdep sibling rimraf,
    • subdep fetch + import.
  • Idempotent symlinkDir calls and the parentSymlinkAlreadyCorrect early return no longer trigger the banner, so a fully no-op run is silent.

Test plan

  • pnpm install in a workspace with config deps — first run prints Installing config dependencies... and Installed config dependencies: ...
  • Re-run pnpm install in the same workspace — neither line is printed
  • Change a config dep version and re-run — both lines print
  • Remove a config dep from pnpm-workspace.yaml and re-run — banner prints (orphan cleanup)

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

Summary by CodeRabbit

  • Bug Fixes

    • Suppressed the "Installing config dependencies..." log when no fetching, linking, or cleanup is required.
    • Ensured the "started" install event is only emitted when actual install/prune work occurs and unified its emission across install phases.
  • Tests

    • Added tests verifying install events emit on real work/removals and do not emit on no-op runs.

Review Change Stack

…en work is actually being done

Previously the message was emitted unconditionally for every config
dependency, before any of the "do we need to fetch / re-symlink?"
checks. As a result the banner printed on every install even when
everything was already cached and correctly linked.

Emit the started event lazily — at most once per install, and only
when an orphan is being removed, a parent or subdep needs fetching,
a parent symlink needs (re)creating, or orphan subdep siblings are
being pruned.

---
Written by an agent (Claude Code, claude-opus-4-7).
@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b8c96116-1a6e-438c-9c6a-c0effbf14700

📥 Commits

Reviewing files that changed from the base of the PR and between 8f79c16 and 39547cf.

📒 Files selected for processing (2)
  • installing/env-installer/src/installConfigDeps.ts
  • installing/env-installer/test/resolveAndInstallConfigDeps.test.ts
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Follow Standard Style with trailing commas, prefer functions over classes, declare functions after they are used (rely on hoisting), and use a single options object for functions with more than two or three arguments
Sort imports in three groups: standard libraries, external dependencies (alphabetically), then relative imports
Write code that explains itself through clear naming and types — do not write comments that merely restate what the code already says; use comments only for non-obvious reasons, hidden invariants, or workarounds

Files:

  • installing/env-installer/test/resolveAndInstallConfigDeps.test.ts
  • installing/env-installer/src/installConfigDeps.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use util.types.isNativeError() instead of instanceof Error when type-checking errors in Jest tests, as instanceof checks can fail across VM realms

Files:

  • installing/env-installer/test/resolveAndInstallConfigDeps.test.ts
🧠 Learnings (1)
📚 Learning: 2026-05-14T09:04:00.133Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11622
File: resolving/npm-resolver/test/publishedBy.test.ts:350-354
Timestamp: 2026-05-14T09:04:00.133Z
Learning: In the pnpm/pnpm repository, ESLint is the authoritative style linter. Do not raise review findings for missing trailing commas in multiline function calls (e.g., `fs.writeFileSync(...)`) when this repo’s ESLint configuration does not report them and lint passes. Prefer deferring to the ESLint results for this specific trailing-comma rule rather than enforcing it manually in code review.

Applied to files:

  • installing/env-installer/test/resolveAndInstallConfigDeps.test.ts
  • installing/env-installer/src/installConfigDeps.ts
🔇 Additional comments (2)
installing/env-installer/src/installConfigDeps.ts (1)

311-315: LGTM!

installing/env-installer/test/resolveAndInstallConfigDeps.test.ts (1)

3-3: LGTM!

Also applies to: 34-42


📝 Walkthrough

Walkthrough

Centralizes emission of the "Installing config dependencies..." started event behind a guarded reportStarted callback and threads it through pruning, fetching/importing, symlinking, and optional-subdependency flows; tests and a changeset were added to validate and document the behavior.

Changes

Conditional logging for config dependency installation

Layer / File(s) Summary
Logging mechanism and initial pruning integration
installing/env-installer/src/installConfigDeps.ts
Introduces a startedEmitted flag and reportStarted() helper that emits the log message once when pruning config dependencies not in the normalized dependency set.
Main install flow integration
installing/env-installer/src/installConfigDeps.ts
Invokes reportStarted() before fetching missing required config dependency packages and before creating or updating top-level dependency symlinks.
Optional subdeps integration
installing/env-installer/src/installConfigDeps.ts
Extends InstallOptionalSubdepsOpts to accept the reportStarted callback, computes/prunes orphanSiblings (emitting reportStarted() when pruning occurs), emits it when optional subdeps require fetching/importing, and short-circuits when existing subdep symlinks already point to the expected target.
Tests: event capture and emission semantics
installing/env-installer/test/resolveAndInstallConfigDeps.test.ts
Adds LogBase/streamParser imports, a stream event capture helper, and a Jest test asserting pnpm:installing-config-deps started/done events only emit when work is performed and emit nothing on a subsequent no-op run.
Release documentation
.changeset/quiet-config-deps.md
Changeset documenting patch releases for @pnpm/installing.env-installer and pnpm, specifying suppression of the "Installing config dependencies..." message when no installation work is needed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • pnpm/pnpm#11725: Both PRs modify installing/env-installer/src/installConfigDeps.ts; this PR's orphan sibling pruning and logging gating build on the optional-subdeps flow introduced there.

Suggested labels

area: config dependencies

Poem

🐰 I nibbled logs with care today,
Only chirped when work made play.
Quiet now when nothing starts,
Hush the console, gentle hearts—
Config hops in tidy sway.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: suppressing the 'Installing config dependencies...' message on no-op installs, which is the core objective addressed across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch install-config-output

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zkochan zkochan marked this pull request as ready for review May 20, 2026 12:12
Copilot AI review requested due to automatic review settings May 20, 2026 12:12
@coderabbitai coderabbitai Bot added the area: config dependencies Changes related to configDependencies. label May 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refines pnpm’s default reporter output for config dependency installation by ensuring the Installing config dependencies... banner is only shown when installConfigDeps actually performs meaningful filesystem work, avoiding noisy output on fully idempotent installs.

Changes:

  • Add a reportStarted() helper to emit the installing-config-deps started log at most once per installConfigDeps invocation.
  • Gate started emission behind specific cleanup/fetch/relink actions (including optional subdep orphan cleanup and fetching).
  • Add a changeset to release the behavior change as a patch for @pnpm/installing.env-installer and pnpm.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
installing/env-installer/src/installConfigDeps.ts Adds one-time started emission and threads it into optional subdep installation to suppress the banner on true no-op runs.
.changeset/quiet-config-deps.md Declares patch releases and documents the reporter-output behavior change.
Comments suppressed due to low confidence (1)

installing/env-installer/src/installConfigDeps.ts:295

  • reportStarted is only called on fetch/import and rimraf paths, but installOptionalSubdeps can still do real filesystem work by (re)creating sibling symlinks via symlinkDir (e.g. when a sibling link is missing/stale but the package is already in the store). In that case this change will suppress the "Installing config dependencies..." banner even though work was performed. Consider using symlinkDir’s return value ({ reused }) to call reportStarted only when the link was actually created/replaced, so no-op symlink checks stay quiet but repairs are still reported.
  await Promise.all(compatibleSubdeps.map(async (subdep) => {
    const subdepFullPkgId = `${subdep.name}@${subdep.version}:${subdep.resolution.integrity}`
    const subdepRelPath = calcLeafGlobalVirtualStorePath(subdepFullPkgId, subdep.name, subdep.version)
    const subdepDirInGlobalVirtualStore = path.join(opts.globalVirtualStoreDir, subdepRelPath, 'node_modules', subdep.name)
    if (!fs.existsSync(path.join(subdepDirInGlobalVirtualStore, 'package.json'))) {
      opts.reportStarted()
      const { fetching } = await opts.store.fetchPackage({

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread installing/env-installer/src/installConfigDeps.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
installing/env-installer/src/installConfigDeps.ts (1)

310-312: 💤 Low value

Consider whether subdep symlink creation should trigger the banner.

The code calls symlinkDir for subdeps (line 312) without a direct reportStarted() call. In contrast, parent symlink creation (line 119) triggers reportStarted() on line 114 when the symlink is missing or incorrect. This asymmetry means:

  • If a parent symlink is missing → banner appears
  • If a subdep symlink is missing (but package exists) → silent operation

This appears intentional based on the PR description listing only five reportStarted() call sites without mentioning subdep symlink creation, but it's worth confirming this design choice.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@installing/env-installer/src/installConfigDeps.ts` around lines 310 - 312,
The subdependency symlink creation using symlinkDir for subdeps (where linkPath
= path.join(opts.parentNodeModulesDir, subdep.name)) currently doesn't call
reportStarted(), unlike the parent symlink branch that calls reportStarted()
around parent symlink creation; add a reportStarted() invocation (with the same
banner message/context used for parent symlinks) immediately before creating the
subdep symlink so missing/incorrect subdep symlinks also trigger the banner, or
if this was intentional add a clear inline comment referencing symlinkDir and
reportStarted to document the asymmetry—update code around symlinkDir, linkPath,
and opts.parentNodeModulesDir accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@installing/env-installer/src/installConfigDeps.ts`:
- Around line 310-312: The subdependency symlink creation using symlinkDir for
subdeps (where linkPath = path.join(opts.parentNodeModulesDir, subdep.name))
currently doesn't call reportStarted(), unlike the parent symlink branch that
calls reportStarted() around parent symlink creation; add a reportStarted()
invocation (with the same banner message/context used for parent symlinks)
immediately before creating the subdep symlink so missing/incorrect subdep
symlinks also trigger the banner, or if this was intentional add a clear inline
comment referencing symlinkDir and reportStarted to document the
asymmetry—update code around symlinkDir, linkPath, and opts.parentNodeModulesDir
accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3c6384e9-de7f-4856-9099-6fdb44a7e8eb

📥 Commits

Reviewing files that changed from the base of the PR and between 0fb7233 and b4db21c.

📒 Files selected for processing (2)
  • .changeset/quiet-config-deps.md
  • installing/env-installer/src/installConfigDeps.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Agent
  • GitHub Check: Compile & Lint
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Follow Standard Style with trailing commas, prefer functions over classes, declare functions after they are used (rely on hoisting), and use a single options object for functions with more than two or three arguments
Sort imports in three groups: standard libraries, external dependencies (alphabetically), then relative imports
Write code that explains itself through clear naming and types — do not write comments that merely restate what the code already says; use comments only for non-obvious reasons, hidden invariants, or workarounds

Files:

  • installing/env-installer/src/installConfigDeps.ts
🧠 Learnings (1)
📚 Learning: 2026-05-14T09:04:00.133Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11622
File: resolving/npm-resolver/test/publishedBy.test.ts:350-354
Timestamp: 2026-05-14T09:04:00.133Z
Learning: In the pnpm/pnpm repository, ESLint is the authoritative style linter. Do not raise review findings for missing trailing commas in multiline function calls (e.g., `fs.writeFileSync(...)`) when this repo’s ESLint configuration does not report them and lint passes. Prefer deferring to the ESLint results for this specific trailing-comma rule rather than enforcing it manually in code review.

Applied to files:

  • installing/env-installer/src/installConfigDeps.ts
🔇 Additional comments (8)
.changeset/quiet-config-deps.md (1)

1-7: LGTM!

installing/env-installer/src/installConfigDeps.ts (7)

43-48: LGTM!


52-52: LGTM!


81-81: LGTM!


108-108: LGTM!

Also applies to: 114-114


254-254: LGTM!


283-287: LGTM!


294-294: LGTM!

zkochan added 2 commits May 20, 2026 14:25
…hen work happens

Captures `streamParser` events around `resolveAndInstallConfigDeps`
to verify the lazy emission introduced in the previous commit:
- fresh install emits both `started` and `done`,
- a follow-up no-op install emits neither,
- removing a config dep still emits `started` (orphan cleanup work).

---
Written by an agent (Claude Code, claude-opus-4-7).
`streamParser` is a `split2` Transform stream that buffers writes until
the first 'data' listener attaches and then drains the whole buffer into
it. Subscribing per-test made the new install-config-deps test capture
events from every earlier test in the file. Move the subscription to
module load and have each test drain the accumulated events around its
own call.

Also drop the "removal" assertion: `resolveAndInstallConfigDeps` does
not prune entries that disappear from the configDeps argument (lockfile
pruning happens at a higher layer), so the scenario it claimed to test
never actually fired the orphan-cleanup path.

---
Written by an agent (Claude Code, claude-opus-4-7).
Copilot AI review requested due to automatic review settings May 20, 2026 12:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

installing/env-installer/test/resolveAndInstallConfigDeps.test.ts:265

  • The new reportStarted() gating has several distinct "work" paths (e.g. orphan cleanup when a config dep is removed, and orphan optional-subdep sibling cleanup). This test only covers fresh install (started+done) and a fully no-op rerun (no events). Adding an assertion for the removal/cleanup path (expecting a started event when a previously-installed config dep is removed) would help prevent regressions in the exact behavior this PR is changing.
test('emits installing-config-deps events only when work is needed', async () => {
  prepareEmpty()
  const opts = createOpts()

  takeConfigDepEvents()
  await resolveAndInstallConfigDeps({
    '@pnpm.e2e/foo': '100.0.0',
  }, opts)
  const firstRunEvents = takeConfigDepEvents()

  expect(firstRunEvents.map(e => e.status)).toEqual(['started', 'done'])
  expect(firstRunEvents.find(e => e.status === 'done')?.deps).toEqual([
    { name: '@pnpm.e2e/foo', version: '100.0.0' },
  ])

  await resolveAndInstallConfigDeps({
    '@pnpm.e2e/foo': '100.0.0',
  }, opts)
  const secondRunEvents = takeConfigDepEvents()

  expect(secondRunEvents).toStrictEqual([])
})

Comment thread installing/env-installer/src/installConfigDeps.ts
Comment thread installing/env-installer/test/resolveAndInstallConfigDeps.test.ts
…relinking

If a config dep's optional subdep is already cached in the global
virtual store but the sibling symlink under the parent's node_modules
is missing or points at a stale target, symlinkDir() does real work
without reportStarted ever firing. Check whether the link already
points at the expected target and only fire reportStarted + symlinkDir
when it doesn't, mirroring the parentSymlinkAlreadyCorrect path.

Also clean up the test-level streamParser listener in afterAll so the
subscription doesn't outlive the test file.

---
Written by an agent (Claude Code, claude-opus-4-7).
@zkochan zkochan merged commit e5e7b72 into main May 20, 2026
15 checks passed
@zkochan zkochan deleted the install-config-output branch May 20, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: config dependencies Changes related to configDependencies.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants