Skip to content

fix: render peer dependency issues on strict error#11450

Merged
zkochan merged 13 commits into
mainfrom
fix/11439
May 4, 2026
Merged

fix: render peer dependency issues on strict error#11450
zkochan merged 13 commits into
mainfrom
fix/11439

Conversation

@zkochan

@zkochan zkochan commented May 4, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #11439.

When strictPeerDependencies: true causes ERR_PNPM_PEER_DEP_ISSUES, the peer dependency issues are again rendered inline — using the same format as pnpm peers check — so users (and CI tools like Renovate) can see what failed without running another command.

The non-strict warning path is unchanged: it still emits the short "Run pnpm peers check" hint.

Behavior

strictPeerDependencies: true:

 ERR_PNPM_PEER_DEP_ISSUES  Unmet peer dependencies

✕ unmet peer react
  Installed: 17.0.2
  Wanted:
    ^18.2.0:
      react-dom@18.2.0
hint: To disable failing on peer dependency issues, add the following to pnpm-workspace.yaml in your project root:

  strictPeerDependencies: false

strictPeerDependencies: false (unchanged):

 WARN  Issues with peer dependencies found. Run "pnpm peers check" to list them.

Implementation

  • Added a new @pnpm/deps.inspection.peers-issues-renderer package at deps/inspection/peers-issues-renderer/, alongside its data producer @pnpm/deps.inspection.peers-checker. It exposes a single renderPeerIssues() that emits the flat issue list previously inlined in pnpm peers check.
  • Removed the duplicated formatter from deps/inspection/commands/src/peers.ts and made the pnpm peers check command consume the new renderer.
  • cli/default-reporter/src/reportError.ts: reportPeerDependencyIssuesError now calls the shared renderPeerIssues() and prefixes the hint block with the rendered output. Tests strip ANSI escapes before substring assertions so they stay correct under FORCE_COLOR=1.

Result: a single renderer is shared between the install error and the pnpm peers check command — output is identical between the two paths.

Test plan

  • pnpm --filter @pnpm/deps.inspection.peers-issues-renderer test — 6 tests pass
  • pnpm --filter @pnpm/cli.default-reporter test — 92 tests pass
  • Manual smoke test: project with react 17 + react-dom 18
    • strictPeerDependencies: true → flat issue list printed inline (same format as pnpm peers check)
    • strictPeerDependencies: false → short warning only
    • pnpm peers check output matches the install error's issue list verbatim

Summary by CodeRabbit

  • New Features
    • Peer dependency issues now render inline in error output when strictPeerDependencies is enabled, matching the peers-check format so failures can be inspected without running a separate check.
  • Documentation
    • Added README documenting the peer-issues renderer.
  • Tests
    • Added tests verifying rendered peer-issues output and formatting.

zkochan added 4 commits May 4, 2026 17:16
Restore the inline tree of peer dependency issues when
`strictPeerDependencies: true` causes `ERR_PNPM_PEER_DEP_ISSUES`, so
users and CI tools (e.g. Renovate) can see the failures without running
`pnpm peers check` separately. The non-strict warning path still emits
the short "Run pnpm peers check" hint.
Copilot AI review requested due to automatic review settings May 4, 2026 15:20
@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

A new shared package @pnpm/deps.inspection.peers-issues-renderer was added and integrated into the CLI reporter and peers check command so peer dependency issues are rendered inline (in pnpm peers check format) when strictPeerDependencies: true, replacing the prior hint-only behavior.

Changes

Peer Dependency Issue Rendering

Layer / File(s) Summary
New Package Scaffolding
deps/inspection/peers-issues-renderer/package.json, deps/inspection/peers-issues-renderer/tsconfig.json, deps/inspection/peers-issues-renderer/tsconfig.lint.json, deps/inspection/peers-issues-renderer/README.md
Adds @pnpm/deps.inspection.peers-issues-renderer package with ES module entrypoints, build/test scripts, deps (chalk, @pnpm/types), TypeScript configs, and README.
Core Rendering Implementation
deps/inspection/peers-issues-renderer/src/index.ts
Implements and exports renderPeerIssues(issuesByProjects): string to format unmet/missing/conflicting peer issues per project, including "Installed" and "Wanted" breakdowns and range quoting rules.
Renderer Tests
deps/inspection/peers-issues-renderer/test/index.ts, deps/inspection/peers-issues-renderer/test/tsconfig.json
Adds Jest tests covering empty, bad, missing, conflicting cases, range-format edge cases, and missing parents.
Add Workspace References
cli/default-reporter/package.json, deps/inspection/commands/package.json, cli/default-reporter/tsconfig.json, deps/inspection/commands/tsconfig.json
Adds the new renderer as a workspace dependency and TypeScript project reference in the CLI reporter and peers command packages.
CLI Error Reporter Integration
cli/default-reporter/src/reportError.ts
Imports renderPeerIssues() and updates reportPeerDependencyIssuesError() to build hints dynamically and prepend rendered peer-issues output (if present) to the error body instead of always showing the pnpm peers check hint.
Peers Command Refactor
deps/inspection/commands/src/peers.ts
Replaces local non-JSON rendering helpers (renderPeerIssuesFlat, formatRequiredBy, formatRange) and chalk usage with shared renderPeerIssues() and prefixes non-JSON output with Issues with peer dependencies found\n\n.
Reporter Tests & Changeset
cli/default-reporter/test/reportingPeerDependencyIssues.ts, .changeset/render-peer-issues-on-strict-error.md
Updates reporter tests to strip ANSI codes and assert inline issue details (e.g., unmet peer a, Installed: 2, b@1.0.0). Adds a changeset documenting behavior and version bumps (refs #11439).

Sequence Diagram

sequenceDiagram
    actor User
    participant pnpm as pnpm CLI
    participant Validator as Peer Validator
    participant Error as Error Handler
    participant Reporter as Default Reporter
    participant Renderer as Peers Issues Renderer
    participant Output as Output Stream

    User->>pnpm: pnpm install (strictPeerDependencies: true)
    pnpm->>Validator: validate peer dependencies
    Validator-->>pnpm: issues found
    pnpm->>Error: raise ERR_PNPM_PEER_DEP_ISSUES
    Error->>Reporter: reportPeerDependencyIssuesError(issuesByProjects)
    Reporter->>Renderer: renderPeerIssues(issuesByProjects)
    Renderer->>Renderer: format unmet/missing/conflicting peers
    Renderer-->>Reporter: formatted string
    Reporter->>Output: write composed error (inline issues + hints)
    Output->>User: display ERR_PNPM_PEER_DEP_ISSUES with details
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A little rabbit hops to show,
Peer issues printed in a row.
Hints once hidden, now made clear,
Install errors bring answers near,
Quick to read, no more to go.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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
Title check ✅ Passed The title 'fix: render peer dependency issues on strict error' accurately describes the main change: restoring inline rendering of peer dependency issue details when strictPeerDependencies is true.
Linked Issues check ✅ Passed The PR comprehensively addresses issue #11439 by restoring inline rendering of peer dependency issues on strict error, allowing users to see failure details without running 'pnpm peers check' separately.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the fix: creating a shared renderPeerIssues module, integrating it into the error reporter, updating the peers command, and adding corresponding tests and configuration.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/11439

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

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 restores inline rendering of the peer dependency issues tree specifically for the ERR_PNPM_PEER_DEP_ISSUES error path (triggered by strictPeerDependencies: true), so CI/log consumers can see the actual peer failures without running pnpm peers check separately (fixes #11439).

Changes:

  • Re-introduces the @pnpm/installing.render-peer-issues workspace package to render peer-issues as a tree.
  • Updates the default CLI reporter to include the rendered tree in strict peer dependency errors.
  • Adds cli-columns to the workspace catalog and wires new dependencies/tests/snapshots.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pnpm-workspace.yaml Adds cli-columns to the shared catalog for consistent dependency management.
pnpm-lock.yaml Locks the new catalog entry and the restored workspace package dependencies.
installing/render-peer-issues/tsconfig.lint.json Adds lint tsconfig for the restored package.
installing/render-peer-issues/tsconfig.json Adds build tsconfig + project references for the restored package.
installing/render-peer-issues/test/tsconfig.json Adds test tsconfig for compiling/running Jest tests.
installing/render-peer-issues/test/index.ts Adds unit tests for peer-issues tree rendering behavior.
installing/render-peer-issues/test/snapshots/index.ts.snap Adds snapshots for the renderer output.
installing/render-peer-issues/src/index.ts Implements the peer issues tree rendering logic.
installing/render-peer-issues/README.md Documents the restored package.
installing/render-peer-issues/package.json Defines package metadata, scripts, and dependencies.
installing/render-peer-issues/CHANGELOG.md Restores historical changelog content for the package.
cli/default-reporter/tsconfig.json Adds TS project reference to the restored renderer package.
cli/default-reporter/test/reportingPeerDependencyIssues.ts Updates reporter test expectation to assert tree content on strict error.
cli/default-reporter/src/reportError.ts Renders the peer-issues tree inline when reporting strict peer dependency errors.
cli/default-reporter/package.json Adds dependency on @pnpm/installing.render-peer-issues.
.changeset/render-peer-issues-on-strict-error.md Announces the restored strict-error inline tree behavior.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

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

Comment thread cli/default-reporter/src/reportError.ts
Comment thread installing/render-peer-issues/src/index.ts Outdated
Comment thread installing/render-peer-issues/src/index.ts Outdated
Comment thread installing/render-peer-issues/README.md Outdated
Comment thread installing/render-peer-issues/CHANGELOG.md Outdated
Comment thread deps/inspection/peers-issues-renderer/package.json

@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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@installing/render-peer-issues/README.md`:
- Around line 11-13: The README's license link `[MIT](LICENSE)` is relative to
installing/render-peer-issues and will 404; update the link target to point at
the repository root license (e.g., change `[MIT](LICENSE)` to `[MIT](/LICENSE)`
or an equivalent root-relative path) so the link resolves to the repo-level
LICENSE from anywhere in the tree.

In `@installing/render-peer-issues/src/index.ts`:
- Around line 38-41: The width calculation for cliColumnsOptions uses
process.stdout.columns directly, which can be undefined in non-TTY CI
environments; update the computation for width (the value assigned to
cliColumnsOptions.width) to fall back to a safe default when opts?.width is not
provided and process.stdout.columns is missing or invalid (e.g., use
process.stdout.columns || a numeric default like 80, or coerce and guard against
NaN) similar to the pattern used in cli/default-reporter so the final width is
always a valid number before subtracting 2.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e835af48-1a7d-4b7f-8541-7a047d3460cb

📥 Commits

Reviewing files that changed from the base of the PR and between 4852e6f and 59f68d0.

⛔ Files ignored due to path filters (2)
  • installing/render-peer-issues/test/__snapshots__/index.ts.snap is excluded by !**/*.snap
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (14)
  • .changeset/render-peer-issues-on-strict-error.md
  • cli/default-reporter/package.json
  • cli/default-reporter/src/reportError.ts
  • cli/default-reporter/test/reportingPeerDependencyIssues.ts
  • cli/default-reporter/tsconfig.json
  • installing/render-peer-issues/CHANGELOG.md
  • installing/render-peer-issues/README.md
  • installing/render-peer-issues/package.json
  • installing/render-peer-issues/src/index.ts
  • installing/render-peer-issues/test/index.ts
  • installing/render-peer-issues/test/tsconfig.json
  • installing/render-peer-issues/tsconfig.json
  • installing/render-peer-issues/tsconfig.lint.json
  • pnpm-workspace.yaml

Comment thread installing/render-peer-issues/README.md Outdated
Comment thread installing/render-peer-issues/src/index.ts Outdated
Copilot AI review requested due to automatic review settings May 4, 2026 15:35
@zkochan zkochan changed the title fix: render peer dependency issues tree on strict error fix: render peer dependency issues on strict error May 4, 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@zkochan

zkochan commented May 4, 2026

Copy link
Copy Markdown
Member Author

Triaged the bot review comments:

  • Copilot — cli-columns width NaN (installing/render-peer-issues/src/index.ts): no longer applicable. The flat renderer doesn't use cli-columns at all (last commit replaced the tree renderer with the same flat formatter pnpm peers check uses).
  • Copilot — formatUnmetPeerMessage styling inconsistency: same as above — that function no longer exists.
  • Copilot — @pnpm/error unused dep in package.json: already removed in the consolidation commit, along with @pnpm/text.tree-renderer and cli-columns.
  • Copilot — reportError.ts body has leading/trailing spaces: not an actual bug. The template literal has no leading whitespace before ${hints…} (line 485 starts at column 0). Smoke-test output confirms hint: lines render with no leading space.
  • Copilot / CodeRabbit — README package name and license link: the README's @pnpm/render-peer-issues references are now @pnpm/installing.render-peer-issues (commit 5af36da). The relative [MIT](LICENSE) link is the existing convention in this repo (see sibling installing/dedupe/issues-renderer/README.md for the same pattern), so left as-is.
  • Copilot — CHANGELOG header: # @pnpm/render-peer-issues is the historical header from before the refactor: rename internal packages to @pnpm/<domain>.<leaf> convention rename in refactor: rename internal packages to @pnpm/<domain>.<leaf> convention #10997. Sibling packages (e.g. installing.dedupe.issues-renderer) follow the same convention of leaving CHANGELOG headers as historical, so left as-is.
  • CodeRabbit — cli-columns width fallback: superseded — cli-columns was dropped entirely in the consolidation commit.

zkochan added 2 commits May 4, 2026 17:56
Move under deps/inspection/ alongside peers-checker, and use noun-form
leaf naming consistent with sibling packages.
Copilot AI review requested due to automatic review settings May 4, 2026 16:11

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 16 out of 17 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

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

Comment thread cli/default-reporter/src/reportError.ts Outdated
Comment thread cli/default-reporter/test/reportingPeerDependencyIssues.ts
zkochan added 2 commits May 4, 2026 18:29
…tests

- Use a single conditional join instead of a multi-line template literal
  that left a trailing newline.
- Strip ANSI escape codes from output before substring assertions so the
  tests stay correct under FORCE_COLOR=1.
Copilot AI review requested due to automatic review settings May 4, 2026 16:37

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 16 out of 17 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

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

Comment thread deps/inspection/peers-issues-renderer/src/index.ts Outdated
Comment thread cli/default-reporter/src/reportError.ts Outdated
Comment thread .changeset/render-peer-issues-on-strict-error.md
zkochan added 2 commits May 4, 2026 18:47
- renderPeerIssues now emits a separate section per distinct foundVersion
  for the same peer name, so different installed versions are no longer
  silently collapsed to the first one.
- The strictPeerDependencies hint no longer adds a trailing empty line.
…ixture

The previous fixture used versions that actually satisfied their ranges
(2.0.0 satisfies ^2.0.0), which would not occur in production data
emitted by checkPeerDependencies.
Copilot AI review requested due to automatic review settings May 4, 2026 16:50

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 16 out of 17 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

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

Comment thread deps/inspection/peers-issues-renderer/README.md
Comment thread pnpm-lock.yaml Outdated
`pnpm install` non-deterministically picked string-width@4.2.3 for
wide-align's optional peer slot; main currently has 1.0.2. Reverting to
keep the diff scoped.
@zkochan zkochan merged commit 55de4fe into main May 4, 2026
12 of 13 checks passed
@zkochan zkochan deleted the fix/11439 branch May 4, 2026 17:44
zkochan added a commit that referenced this pull request May 4, 2026
Fixes #11439.

When `strictPeerDependencies: true` causes `ERR_PNPM_PEER_DEP_ISSUES`, the peer dependency issues are again rendered inline — using the **same format as `pnpm peers check`** — so users (and CI tools like Renovate) can see what failed without running another command.

The non-strict warning path is unchanged: it still emits the short "Run `pnpm peers check`" hint.

### Behavior

`strictPeerDependencies: true`:
```
 ERR_PNPM_PEER_DEP_ISSUES  Unmet peer dependencies

✕ unmet peer react
  Installed: 17.0.2
  Wanted:
    ^18.2.0:
      react-dom@18.2.0
hint: To disable failing on peer dependency issues, add the following to pnpm-workspace.yaml in your project root:

  strictPeerDependencies: false
```

`strictPeerDependencies: false` (unchanged):
```
 WARN  Issues with peer dependencies found. Run "pnpm peers check" to list them.
```

### Implementation

- Added a new `@pnpm/deps.inspection.peers-issues-renderer` package at `deps/inspection/peers-issues-renderer/`, alongside its data producer `@pnpm/deps.inspection.peers-checker`. It exposes a single `renderPeerIssues()` that emits the flat issue list previously inlined in `pnpm peers check`.
- Removed the duplicated formatter from `deps/inspection/commands/src/peers.ts` and made the `pnpm peers check` command consume the new renderer.
- `cli/default-reporter/src/reportError.ts`: `reportPeerDependencyIssuesError` now calls the shared `renderPeerIssues()` and prefixes the hint block with the rendered output. Tests strip ANSI escapes before substring assertions so they stay correct under `FORCE_COLOR=1`.

Result: a single renderer is shared between the install error and the `pnpm peers check` command — output is identical between the two paths.
@zkochan zkochan added this to the v11.0 milestone May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rendering peer issues tree by default in v11

2 participants