Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG](arborist) different peerSets installed in root vs workspace #4269

Open
lukekarrys opened this issue Oct 29, 2021 · 0 comments
Open

[BUG](arborist) different peerSets installed in root vs workspace #4269

lukekarrys opened this issue Oct 29, 2021 · 0 comments
Labels
Needs Triage needs review for next steps ws:arborist Related to the arborist workspace

Comments

@lukekarrys
Copy link
Contributor

What / Why

A tree with a conflicting peerDependencies ends up with different versions when installed in the root vs a workspace.

How

Current Behavior

// conflicting peerSet
project -> (a@2)
a@2 -> (b), PEER(c@2), PEER(d@2)
b -> PEER(c@1), PEER(d@1)
c -> ()
d@1 -> PEER(c@1)
d@2 -> PEER(c@2)

Given that tree, all dependencies get hoisted to the root when installed in both cases, but c and d end up resolving to different versions in each case.

Steps to Reproduce

Installed in the root

arborist reify --add="@lukekarrys/workspace-peer-dep-infinite-loop-a@2"

npm ls --all

test-dir@1.0.0 /Users/lukekarrys/Desktop/arborist-tests/test-dir
├─┬ @lukekarrys/workspace-peer-dep-infinite-loop-a@2.0.1
│ ├─┬ @lukekarrys/workspace-peer-dep-infinite-loop-b@1.0.0
│ │ ├── @lukekarrys/workspace-peer-dep-infinite-loop-c@2.0.0 deduped invalid: "1.0.0" from node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-b
│ │ └── @lukekarrys/workspace-peer-dep-infinite-loop-d@2.0.0 deduped invalid: "1.0.0" from node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-b
│ ├── @lukekarrys/workspace-peer-dep-infinite-loop-c@2.0.0 invalid: "1.0.0" from node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-b
│ └─┬ @lukekarrys/workspace-peer-dep-infinite-loop-d@2.0.0 invalid: "1.0.0" from node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-b
│   └── @lukekarrys/workspace-peer-dep-infinite-loop-c@2.0.0 deduped invalid: "1.0.0" from node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-b
└── a@1.0.0 -> ./a

package-lock.json

{
  "": {
    "name": "test-dir",
    "version": "1.0.0",
    "license": "ISC",
    "workspaces": [
      "a"
    ],
    "dependencies": {
      "@lukekarrys/workspace-peer-dep-infinite-loop-a": "^2.0.1"
    }
  },
  "a": {
    "version": "1.0.0",
    "license": "ISC"
  },
  "node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-a": {
    "version": "2.0.1",
    "resolved": "https://registry.npmjs.org/@lukekarrys/workspace-peer-dep-infinite-loop-a/-/workspace-peer-dep-infinite-loop-a-2.0.1.tgz",
    "integrity": "sha512-giB57Db/oYd7/McsynhxFS+76F7Th9QStIBdgicVhITDJ9czIBbcfYKoLGOvmexfHfdkRirXTBs418tvwir8Ag==",
    "dependencies": {
      "@lukekarrys/workspace-peer-dep-infinite-loop-b": "1.0.0"
    },
    "peerDependencies": {
      "@lukekarrys/workspace-peer-dep-infinite-loop-c": "2.0.0",
      "@lukekarrys/workspace-peer-dep-infinite-loop-d": "2.0.0"
    }
  },
  "node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-b": {
    "version": "1.0.0",
    "resolved": "https://registry.npmjs.org/@lukekarrys/workspace-peer-dep-infinite-loop-b/-/workspace-peer-dep-infinite-loop-b-1.0.0.tgz",
    "integrity": "sha512-+GvjbbvuGzZvsjQxKTjQkbIJrtNt56Gv6vSrARlORG8zV9hmKq42nLzs+WxtnK660GLAdEDfX9I6hgBNbS7/mA==",
    "peerDependencies": {
      "@lukekarrys/workspace-peer-dep-infinite-loop-c": "1.0.0",
      "@lukekarrys/workspace-peer-dep-infinite-loop-d": "1.0.0"
    }
  },
  "node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-c": {
    "version": "2.0.0",
    "resolved": "https://registry.npmjs.org/@lukekarrys/workspace-peer-dep-infinite-loop-c/-/workspace-peer-dep-infinite-loop-c-2.0.0.tgz",
    "integrity": "sha512-V97f4sg8/qDVsneWvvxRolgQHlo4d1fywWYT0T1O9fo9c5WInL74CZ+RmHgaKIBVWXUdQpGRMf7K98TVT8J16A==",
    "peer": true
  },
  "node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-d": {
    "version": "2.0.0",
    "resolved": "https://registry.npmjs.org/@lukekarrys/workspace-peer-dep-infinite-loop-d/-/workspace-peer-dep-infinite-loop-d-2.0.0.tgz",
    "integrity": "sha512-aJXF9gmAN0dAJZGQ5Midr18ufPU9uGB7ce7LjwF0+tqTwxQroHlqBo/WID51ERBOHRldZfdsKrxJd7O3EKj8kg==",
    "peer": true,
    "peerDependencies": {
      "@lukekarrys/workspace-peer-dep-infinite-loop-c": "2.0.0"
    }
  },
  "node_modules/a": {
    "resolved": "a",
    "link": true
  }
}

Installed in a workspace

arborist reify --add="@lukekarrys/workspace-peer-dep-infinite-loop-a@2" --workspace="a"

npm ls --all

test-dir@1.0.0 /Users/lukekarrys/Desktop/arborist-tests/test-dir
└─┬ a@1.0.0 -> ./a
  └─┬ @lukekarrys/workspace-peer-dep-infinite-loop-a@2.0.1
    ├─┬ @lukekarrys/workspace-peer-dep-infinite-loop-b@1.0.0
    │ ├── @lukekarrys/workspace-peer-dep-infinite-loop-c@1.0.0 deduped invalid: "2.0.0" from node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-a
    │ └── @lukekarrys/workspace-peer-dep-infinite-loop-d@1.0.0 deduped invalid: "2.0.0" from node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-a
    ├── @lukekarrys/workspace-peer-dep-infinite-loop-c@1.0.0 invalid: "2.0.0" from node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-a
    └─┬ @lukekarrys/workspace-peer-dep-infinite-loop-d@1.0.0 invalid: "2.0.0" from node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-a
      └── @lukekarrys/workspace-peer-dep-infinite-loop-c@1.0.0 deduped invalid: "2.0.0" from node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-a

package-lock.json

{
  "": {
    "name": "test-dir",
    "version": "1.0.0",
    "license": "ISC",
    "workspaces": [
      "a"
    ]
  },
  "a": {
    "version": "1.0.0",
    "license": "ISC",
    "dependencies": {
      "@lukekarrys/workspace-peer-dep-infinite-loop-a": "^2.0.1"
    }
  },
  "node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-a": {
    "version": "2.0.1",
    "resolved": "https://registry.npmjs.org/@lukekarrys/workspace-peer-dep-infinite-loop-a/-/workspace-peer-dep-infinite-loop-a-2.0.1.tgz",
    "integrity": "sha512-giB57Db/oYd7/McsynhxFS+76F7Th9QStIBdgicVhITDJ9czIBbcfYKoLGOvmexfHfdkRirXTBs418tvwir8Ag==",
    "dependencies": {
      "@lukekarrys/workspace-peer-dep-infinite-loop-b": "1.0.0"
    },
    "peerDependencies": {
      "@lukekarrys/workspace-peer-dep-infinite-loop-c": "2.0.0",
      "@lukekarrys/workspace-peer-dep-infinite-loop-d": "2.0.0"
    }
  },
  "node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-b": {
    "version": "1.0.0",
    "resolved": "https://registry.npmjs.org/@lukekarrys/workspace-peer-dep-infinite-loop-b/-/workspace-peer-dep-infinite-loop-b-1.0.0.tgz",
    "integrity": "sha512-+GvjbbvuGzZvsjQxKTjQkbIJrtNt56Gv6vSrARlORG8zV9hmKq42nLzs+WxtnK660GLAdEDfX9I6hgBNbS7/mA==",
    "peerDependencies": {
      "@lukekarrys/workspace-peer-dep-infinite-loop-c": "1.0.0",
      "@lukekarrys/workspace-peer-dep-infinite-loop-d": "1.0.0"
    }
  },
  "node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-c": {
    "version": "1.0.0",
    "resolved": "https://registry.npmjs.org/@lukekarrys/workspace-peer-dep-infinite-loop-c/-/workspace-peer-dep-infinite-loop-c-1.0.0.tgz",
    "integrity": "sha512-Mo0OMqE85adQNUae/K1SR8aCtOAv0GQ6vZ4vZ3NdB+J+J1sJ2mffliJeGbzHgN9Le9Njc8sVZ114GpU/pdddEA==",
    "peer": true
  },
  "node_modules/@lukekarrys/workspace-peer-dep-infinite-loop-d": {
    "version": "1.0.0",
    "resolved": "https://registry.npmjs.org/@lukekarrys/workspace-peer-dep-infinite-loop-d/-/workspace-peer-dep-infinite-loop-d-1.0.0.tgz",
    "integrity": "sha512-TjMnL1cPV0UcpbU+NyCKQrXQN3lI7Ksz3zn6drJg3KL+6AxDFit/Aw6BtCL6tHmm5G+U7eIzjLPAHqlXIFrSVw==",
    "peer": true,
    "peerDependencies": {
      "@lukekarrys/workspace-peer-dep-infinite-loop-c": "1.0.0"
    }
  },
  "node_modules/a": {
    "resolved": "a",
    "link": true
  }
}

Expected Behavior

I think in the second example when installing in a workspace, c@2 and d@2 should be installed.

References

npm/arborist#343

lukekarrys referenced this issue in npm/arborist Oct 29, 2021
Fix: npm/cli#3933

Previously, installing a tree that causes peerSets to be pruned would
cause an infinite loop when done inside a workspace. This patch stops
that check if the entryEdge is a workspace, the same as being done if it
were the project root.

This patch also adds some incorrect tests that were discovered when
debugging this, and will be fixed in the future (#347 #348).
isaacs referenced this issue in npm/arborist Nov 3, 2021
Fix: npm/cli#3933

Previously, installing a tree that causes peerSets to be pruned would
cause an infinite loop when done inside a workspace. This patch stops
that check if the entryEdge is a workspace, the same as being done if it
were the project root.

This patch also adds some incorrect tests that were discovered when
debugging this, and will be fixed in the future (#347 #348).

PR-URL: #343
Credit: @lukekarrys
Close: #343
Reviewed-by: @isaacs
@fritzy fritzy transferred this issue from npm/arborist Jan 20, 2022
@fritzy fritzy added Needs Triage needs review for next steps ws:arborist Related to the arborist workspace labels Jan 20, 2022
@fritzy fritzy changed the title [BUG] different peerSets installed in root vs workspace [BUG](arborist) different peerSets installed in root vs workspace Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Triage needs review for next steps ws:arborist Related to the arborist workspace
Projects
None yet
Development

No branches or pull requests

2 participants