Skip to content

pnpm install fails silently when peerDependencyRules is used with strict-peer-dependencies #8859

@47hao

Description

@47hao

Verify latest release

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

pnpm version

9.14.2

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

CLI

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

https://github.com/47hao/pnpm-issue-repro

Reproduction steps

  1. Enable strict-peer-dependencies
  2. Introduce a peer dependency issue; for example, have the following in package.json:
"dependencies": {
    "react": "18.2.0",
    "react-dom": "16.9.0"
  }
  1. Address the peer dependency issue using peerDependencyRules, such as by adding this snippet to the package.json. Using allowAny should also work, based on strict-peer-dependencies in combination with pnpm.peerDependencyRules.allowAny suppresses error message but exit code is 1 #8382
"pnpm": {
    "peerDependencyRules": {
      "allowedVersions": {
        "react-dom@16>react": "18"
      }
    }
  }
  1. Run pnpm install. Nothing is logged, the "Done in X" success message is missing, and the exit code is 1.
    image

Describe the Bug

During a pnpm install, where strict-peer-dependencies is enabled and peer dependency issues are fixed via peerDependencyRules:

  1. All direct peer issues, before considering peerDependencyRules, are aggregated in peerDependencyIssuesByProjects
  2. A peer dependency error is thrown because peerDependencyRules is not empty.
  3. The errors are rendered, during which peerDependencyRules are parsed and applied. That fixes all the peer dependency issues, so the error rendering function outputs nothing.

The observed outcome is exit code 1 (due to step 2) and no error logging (due to step 3).

This bug is new to pnpm v9+ because peerDependencyRulesare now only considered when logging; before, they were applied as patches. #7758 moved the effects of peerDependencyRules from upstream of the error throw to downstream of it.

Related issues:

Expected Behavior

pnpm install succeeds with exit code 0.

The processing logic for peer dependency errors (currently in the render function) should run before throwing a PeerDependencyIssuesError, and the error throw should be conditioned on its result.

Which Node.js version are you using?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Priority

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions