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

yarn seems to be erroneously logging incorrect peer dependency warnings #4433

Closed
bjankord opened this issue Sep 13, 2017 · 13 comments · Fixed by #4478
Closed

yarn seems to be erroneously logging incorrect peer dependency warnings #4433

bjankord opened this issue Sep 13, 2017 · 13 comments · Fixed by #4478
Assignees
Labels

Comments

@bjankord
Copy link

bjankord commented Sep 13, 2017

Do you want to request a feature or report a bug?

Bug Report

What is the current behavior?

tl;dr yarn seems to be erroneously logging incorrect peer dependency warnings even though the dependencies install correctly as one would expect given the package.json files.

We have a monorepo structure with lerna using independent versioning and yarn workspaces. When we run yarn or yarn install we are seeing multiple incorrect peer dependency warnings.

We have multiple npm packages in the monorepo and some of the packages have 1 way dependencies amongst themselves.

For example:

  • package-B has a dependency / peerDependency on package-A ^1.0.0
  • package-C has a dependency / peerDependency on package-A ^1.0.0

package-B and package-C have dependencies and peerDependencies which look like this:

"peerDependencies": {
    "package-A": "^1.0.0",
  },
  "dependencies": {
    "package-A": "^1.0.0",
  },

Even though there are multiple incorrect peer dependency warnings, the dependencies are installed as expected in the root node_modules directory which satisfies the specified dependencies and peerDependencies for each package.

If the current behavior is a bug, please provide the steps to reproduce.
I'm trying to create a reduced test-case, but you can reproduce the warnings in our project repo, terra-core, in this branch: https://github.com/cerner/terra-core/tree/update-lerna

Steps to repro:

  • Clone repo: git clone https://github.com/cerner/terra-core.git
  • Checkout the update-lerna branch: git fetch origin git checkout --track origin/update-lerna
  • Run yarn to install deps: yarn

Once it gets to the Linking dependencies... step, it will start to log multiple warnings around incorrect peer dependencies.

Here is the output related to the warnings:

Output

   yarn install v1.0.1
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
[3/5] 🚚  Fetching packages...
[4/5] 🔗  Linking dependencies...
warning "ajv-keywords@1.5.1" has incorrect peer dependency "ajv@>=4.10.0".
warning "postcss-reporter@4.0.0" has incorrect peer dependency "postcss@^6.0.0".
warning "babel-loader@7.1.2" has incorrect peer dependency "webpack@2 || 3".
warning "extract-text-webpack-plugin@2.1.2" has incorrect peer dependency "webpack@^2.2.0".
warning "html-webpack-plugin@2.30.1" has incorrect peer dependency "webpack@1 || ^2 || ^2.1.0-beta || ^2.2.0-rc || ^3".
warning "sass-loader@6.0.6" has incorrect peer dependency "node-sass@^4.0.0".
warning "sass-loader@6.0.6" has incorrect peer dependency "webpack@^2.0.0 || >= 3.0.0-rc.0 || ^3.0.0".
warning "webpack-dev-server@2.7.1" has incorrect peer dependency "webpack@^2.2.0 || ^3.0.0".
warning "webpack-dev-middleware@1.12.0" has incorrect peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0".
warning "terra-alert@1.6.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-alert@1.6.0" has incorrect peer dependency "terra-button@^1.8.0".
warning "terra-alert@1.6.0" has incorrect peer dependency "terra-icon@^1.9.0".
warning "terra-alert@1.6.0" has incorrect peer dependency "terra-responsive-element@^1.8.0".
warning "terra-arrange@1.9.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-badge@1.8.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-badge@1.8.0" has incorrect peer dependency "terra-mixins@^1.9.0".
warning "terra-button-group@1.9.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-button-group@1.9.0" has incorrect peer dependency "terra-button@^1.8.0".
warning "terra-button@1.8.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-card@1.3.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-card@1.3.0" has incorrect peer dependency "terra-mixins@^1.9.0".
warning "terra-content-container@1.8.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-date-picker@1.10.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-date-picker@1.10.0" has incorrect peer dependency "terra-button@^1.8.0".
warning "terra-date-picker@1.10.0" has incorrect peer dependency "terra-form@^1.8.0".
warning "terra-date-picker@1.10.0" has incorrect peer dependency "terra-icon@^1.9.0".
warning "terra-date-picker@1.10.0" has incorrect peer dependency "terra-responsive-element@^1.8.0".
warning "terra-demographics-banner@1.9.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-dynamic-grid@1.3.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-embedded-content-consumer@1.3.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-embedded-content-consumer@1.3.0" has incorrect peer dependency "xfc@^1.0.0".
warning "terra-form@1.8.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-grid@3.12.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-heading@1.9.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-icon@1.9.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-image@1.8.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-list@1.9.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-list@1.9.0" has incorrect peer dependency "terra-icon@^1.9.0".
warning "terra-menu@1.0.0" has incorrect peer dependency "terra-arrange@^1.9.0".
warning "terra-menu@1.0.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-menu@1.0.0" has incorrect peer dependency "terra-content-container@^1.8.0".
warning "terra-menu@1.0.0" has incorrect peer dependency "terra-icon@^1.9.0".
warning "terra-menu@1.0.0" has incorrect peer dependency "terra-list@^1.9.0".
warning "terra-menu@1.0.0" has incorrect peer dependency "terra-popup@^1.8.0".
warning "terra-menu@1.0.0" has incorrect peer dependency "terra-slide-group@^1.8.0".
warning "terra-modal-manager@1.10.0" has incorrect peer dependency "react-redux@^5.0.4".
warning "terra-modal-manager@1.10.0" has incorrect peer dependency "redux@^3.6.0".
warning "terra-modal-manager@1.10.0" has incorrect peer dependency "terra-app-delegate@^1.4.0".
warning "terra-modal-manager@1.10.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-overlay@1.8.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-overlay@1.8.0" has incorrect peer dependency "terra-icon@^1.9.0".
warning "terra-popup@1.8.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-popup@1.8.0" has incorrect peer dependency "terra-icon@^1.9.0".
warning "terra-profile-image@1.7.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-profile-image@1.7.0" has incorrect peer dependency "terra-image@^1.8.0".
warning "terra-progress-bar@1.8.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-responsive-element@1.8.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-search-field@1.9.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-search-field@1.9.0" has incorrect peer dependency "terra-button@^1.8.0".
warning "terra-search-field@1.9.0" has incorrect peer dependency "terra-form@^1.8.0".
warning "terra-search-field@1.9.0" has incorrect peer dependency "terra-icon@^1.9.0".
warning "terra-slide-group@1.8.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-slide-panel@1.8.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-status@1.9.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-table@1.9.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-table@1.9.0" has incorrect peer dependency "terra-icon@^1.9.0".
warning "terra-text@1.8.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-theme-provider@1.3.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-theme-provider@1.3.0" has incorrect peer dependency "terra-mixins@^1.9.0".
warning "terra-time-input@1.9.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-time-input@1.9.0" has incorrect peer dependency "terra-form@^1.8.0".
warning "terra-toggle-button@1.9.0" has incorrect peer dependency "terra-arrange@^1.9.0".
warning "terra-toggle-button@1.9.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "terra-toggle-button@1.9.0" has incorrect peer dependency "terra-button@^1.8.0".
warning "terra-toggle-button@1.9.0" has incorrect peer dependency "terra-icon@^1.9.0".
warning "terra-toggle-button@1.9.0" has incorrect peer dependency "terra-toggle@^1.8.0".
warning "terra-toggle@1.8.0" has incorrect peer dependency "terra-base@^2.3.0".
warning "react-intl@2.4.0" has incorrect peer dependency "prop-types@^15.5.4".
warning "react-redux@5.0.6" has incorrect peer dependency "redux@^2.0.0 || ^3.0.0".

What is the expected behavior?
Running through the steps to reproduce the bug does not trigger erroneous incorrect peer dependency warnings.

Please mention your node.js, yarn and operating system version.

Software Version
Node.js 8.4.0
yarn 1.0.1
OS OS X El Capitan v10.11.6

Additional Notes
I spent some time looking through the Yarn codebase to see if I could better understand this issue. I ended up here but wasn't able to spot anything around what causes this issue.

Related issues
#4342
#4064
#2387
This may have some relation with this issue as well: #4432

@bjankord bjankord changed the title yarn seems to be errorenously logging incorrect peer dependency warnings even though the dependencies install correctly as one would expect given the package.json files yarn seems to be erroneously logging incorrect peer dependency warnings Sep 13, 2017
@BYK
Copy link
Member

BYK commented Sep 13, 2017

@bjankord thanks for tidying up those issues. These all look stemming from the same root cause to me so may be we should consolidate all of them into a single issue (may be this one?). What do you think?

@bjankord
Copy link
Author

+1, sounds good to me.

@devoto13
Copy link
Contributor

It seems to be caused by changes in #3803.

Easy repro is to clone Yarn repo and $ yarn install it :)
It produces warning "ajv-keywords@1.5.1" has incorrect peer dependency "ajv@>=4.10.0". using 1.0.2.

$ yarn why ajv-keywords
yarn why v1.0.2
[1/4] 🤔  Why do we have the module "ajv-keywords"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
info Reasons this module exists
   - "eslint#table" depends on it
   - "webpack" depends on it
$ yarn list ajv-keywords ajv table eslint webpack
yarn list v1.0.2
├─ ajv-keywords@1.5.1 has peer on "ajv": ">=4.10.0"
├─ ajv@4.11.8 satisfies peer
├─ eslint@4.3.0
│  └─ ajv@5.2.2
├─ table@4.0.1 has "ajv": "^4.7.0" and "ajv-keywords": "^1.0.0" in dependencies
└─ webpack@2.6.0 has ajv": "^4.7.0" and "ajv-keywords": "^1.1.1" in dependencies

From the linked PR it looks like one should satisfy every peer dependency in the root package.json even if it was already satisfied lower in the dependency chain. At least I can fix warning in Yarn repo by doing:

$ yarn add ajv@4.11.8

Is "one should satisfy every peer dependency in the root package.json even if it was already satisfied lower in the dependency chain" really the intended behavior?

Maybe I don't understand all the implications, but I don't see any sense in the warning for the given dependency tree. Since table and webpack already satisfied peerDependencies of ajv-keywords why one should have to add it in the root package.json. And if table and webpack want to ensure that package, who depends on them, will get single instance of ajv-keywords they should have it in their own peerDependencies. No?

cc @kaylieEB

@kaylie-alexa
Copy link
Member

kaylie-alexa commented Sep 14, 2017

Definitely seems like the same issue as #4342. The PR (#3803) was to fix incorrect semver modules from being copied in nested modules structure, but we can revert it for now since we have selective resolutions to force a nested module to have a particular version. This would restore the old bug (#3710) by swallowing the warning but at least there's a workaround. @BYK I can't work on the real fix atm, maybe next week or so -- what do you think?

fyi, I think #2387 is a separate issue.

@BYK BYK self-assigned this Sep 15, 2017
BYK added a commit that referenced this issue Sep 15, 2017
**Summary**

Fixes #4446, fixes #4433. Follow up to #3893. The fix in #3893 was
too aggressive, allowing only top-level dependencies to be used in
peer dependency resolution which was incorrect. This patch allows
resolving peer dependencies from the same or higher levels in the
dependency tree.

**Test plan**

Additional unit and integration tests.
@BYK BYK closed this as completed in #4478 Sep 16, 2017
BYK added a commit that referenced this issue Sep 16, 2017
…4478)

**Summary**

Fixes #4446, fixes #4433, fixes #2688, fixes #2387. Follow up to #3803. The fix in #3893 was
too aggressive, allowing only top-level dependencies to be used in
peer dependency resolution which was incorrect. This patch allows
resolving peer dependencies from the same or higher levels in the
dependency tree.

**Test plan**

Additional unit and integration tests.
@elsurudo
Copy link

Has this been released yet?

@BYK
Copy link
Member

BYK commented Sep 27, 2017

@elsurudo yup: 1.1.0

@bjankord
Copy link
Author

Thanks for the quick fix on this!

joaolucasl pushed a commit to joaolucasl/yarn that referenced this issue Oct 27, 2017
…arnpkg#4478)

**Summary**

Fixes yarnpkg#4446, fixes yarnpkg#4433, fixes yarnpkg#2688, fixes yarnpkg#2387. Follow up to yarnpkg#3803. The fix in yarnpkg#3893 was
too aggressive, allowing only top-level dependencies to be used in
peer dependency resolution which was incorrect. This patch allows
resolving peer dependencies from the same or higher levels in the
dependency tree.

**Test plan**

Additional unit and integration tests.
@lukescott
Copy link

lukescott commented Jan 5, 2018

It looks like this mostly fixed the issue for me. But I'm running into a case with beta version numbers that still logs peer dependency errors in workspace mode:

warning "workspace-aggregator-1a6f09e5-756e-46d3-b91e-d2f8fdf04e82 > mypackagename > babel-core@7.0.0-bridge.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "workspace-aggregator-1a6f09e5-756e-46d3-b91e-d2f8fdf04e82 > mypackagename > babel-loader@8.0.0-beta.0" has unmet peer dependency "@babel/core@7 || ^7.0.0-beta || ^7.0.0-rc".
warning "workspace-aggregator-1a6f09e5-756e-46d3-b91e-d2f8fdf04e82 > mypackagename > @babel/preset-react > @babel/plugin-syntax-jsx@7.0.0-beta.36" has unmet peer dependency "@babel/core@7.0.0-beta.36".
warning "workspace-aggregator-1a6f09e5-756e-46d3-b91e-d2f8fdf04e82 > mypackagename > @babel/preset-react > @babel/plugin-transform-react-display-name@7.0.0-beta.36" has unmet peer dependency "@babel/core@7.0.0-beta.36".
warning "workspace-aggregator-1a6f09e5-756e-46d3-b91e-d2f8fdf04e82 > mypackagename > @babel/preset-react > @babel/plugin-transform-react-jsx@7.0.0-beta.36" has unmet peer dependency "@babel/core@7.0.0-beta.36".
warning "workspace-aggregator-1a6f09e5-756e-46d3-b91e-d2f8fdf04e82 > mypackagename > @babel/preset-react > @babel/plugin-transform-react-jsx-self@7.0.0-beta.36" has unmet peer dependency "@babel/core@7.0.0-beta.36".
warning "workspace-aggregator-1a6f09e5-756e-46d3-b91e-d2f8fdf04e82 > mypackagename > @babel/preset-react > @babel/plugin-transform-react-jsx-source@7.0.0-beta.36" has unmet peer dependency "@babel/core@7.0.0-beta.36".

This only happens when a beta package is not listed in every work space package. For example, I use @babel/preset-react only in one of my packages, but use @babel/preset-typescript in all of them. The error is only logged for the former but not the latter.

If I add "@babel/core": "7.0.0-beta.36" to the root package.json file the warnings go away. This dependency is listed in every package.json file though...

@nilobarp
Copy link

Still getting warnings with yarn v 1.3.2

warning "@storybook/react > @storybook/ui > react-icons > react-icon-base@2.1.0" has unmet peer dependency "prop-types@*".
warning " > storybook-readme@3.1.1" has unmet peer dependency "prop-types@^15.6.0".

package installed

"prop-types": "^15.6.0"

@rolandjitsu
Copy link

rolandjitsu commented Feb 13, 2018

I'm still seeing something similar:

warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/common@0.4.0" has unmet peer dependency "@bbpviz/camera@^3.0.0".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/common@0.4.0" has unmet peer dependency "@bbpviz/net@^3.1.1".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/common@0.4.0" has unmet peer dependency "@bbpviz/renderer@^8.3.1".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/common@0.4.0" has unmet peer dependency "@bbpviz/utils@^0.28.2".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/common@0.4.0" has unmet peer dependency "material-ui@1.0.0-beta.33".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/common@0.4.0" has unmet peer dependency "react@^16.2.0".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/common@0.4.0" has unmet peer dependency "react-transition-group@^2.2.1".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/common@0.4.0" has unmet peer dependency "redux@^3.7.2".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/common@0.4.0" has unmet peer dependency "rxjs@^5.5.6".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/utils@0.4.0" has unmet peer dependency "@bbpviz/net@^3.1.1".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/utils@0.4.0" has unmet peer dependency "@bbpviz/renderer@^8.3.1".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/utils@0.4.0" has unmet peer dependency "file-saver@^1.3.3".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/utils@0.4.0" has unmet peer dependency "rxjs@^5.5.6".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/common > jest-environment-jsdom-global@1.0.3" has unmet peer dependency "jest-environment-jsdom@22.x".

It seems to happen for peer deps that are required by workspaces, even though they are eventually deps in other workspaces:

// workspaces/w1/package.json
{
    "name": "w1",
    "dependencies": {
        "package-a": "^1.0.0",
        "package-b": "^2.0.0"
    }
}

// workspaces/w2/package.json
{
    "name": "w2",
    "peerDependencies": {
        "package-a": "^1.0.0"
    }
}

// root package.json
{
    "name": "",
    "dependencies": {}
}

Running yarn install at root would complain that package-a has unmet peer dep.

@vsviridov
Copy link

Getting same behaviour for namespaced packages...

@DanielRuf
Copy link
Contributor

I still see the same with yarn 1.15.2 for yarn global add relaxedjs.

Can we reopen this?

@ajmas
Copy link

ajmas commented May 31, 2019

Just experienced this. The warning I get:

warning " > vue-hellojs@0.0.4" has unmet peer dependency "vue@>= 1.0.0".

Though vue@2.6.10 is included as a dependency of @quasar/app@1.0.0-rc.6.

Yarn version is 1.16.0 on macOS 10.14.4, using nodejs v10.15.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.