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

Make package deprecation warnings more useful #6707

Closed
1 task
evelant opened this issue Jun 22, 2023 · 4 comments · Fixed by #7090
Closed
1 task

Make package deprecation warnings more useful #6707

evelant opened this issue Jun 22, 2023 · 4 comments · Fixed by #7090
Assignees

Comments

@evelant
Copy link

evelant commented Jun 22, 2023

Describe the user story

When running pnpm install it's common to get deprecation warnings that aren't very useful or actionable because they come from unknown depepdencies of dependencies that the user has little/no control over. For example:

 WARN  deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
 WARN  deprecated @oclif/screen@3.0.4: Deprecated in favor of @oclif/core
 WARN  deprecated read-package-tree@5.1.6: The functionality that this package provided is now in @npmcli/arborist
 WARN  deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
 WARN  deprecated har-validator@5.1.5: this library is no longer supported
 WARN  deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
 WARN  deprecated readdir-scoped-modules@1.1.0: This functionality has been moved to @npmcli/fs
 WARN  deprecated flatten@1.0.3: flatten is deprecated in favor of utility frameworks such as lodash.
 WARN  deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
 WARN  deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
 WARN  deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility

None of those are direct dependencies of my library. I don't know which package is including them or why and there's not much action I can take with the information.

Describe the solution you'd like

Two possible solutions:

  1. Don't show deprecation warnings for depdencies that aren't in package.json
  2. Show the path of depdencies to the package that's being warned about and a link to the repo of the package importing the deprecated dependency. This at least informs users why the warning is happening and gives them a pointer to where they can contribute or request a fix.

Describe the drawbacks of your solution

  1. Hiding deprecations of indrect dependencies might hide an important message. In practice I've never seen a useful or actionable deprecation warning from an indirect dependency however. It's usually just noise to be ignored.
  2. No drawbacks for to showing more useful information that I can see.

Describe alternatives you've considered

Perhaps a single warning could be shown such as warn: 17 indirect dependencies are deprecated. run with --show-all-deprecated to list them?

@zkochan
Copy link
Member

zkochan commented Jun 22, 2023

Hiding deprecations of indrect dependencies might hide an important message. In practice I've never seen a useful or actionable deprecation warning from an indirect dependency however. It's usually just noise to be ignored.

We used to show only the deprecation messages of direct dependencies but then one time a user has spent days investigating an issue because pnpm wasn't printing the message (related change #4231). Both npm and Yarn print all the deprecation messages.

Perhaps a single warning could be shown such as warn: 17 indirect dependencies are deprecated. run with --show-all-deprecated to list them?

Something like this could work. All the deprecation messages are also written to the lockfile. So, it would be possible to just search for deprecated: in the lockfile.


Also, pnpm is able to mute some deprecation messages using the setting: https://pnpm.io/package_json#pnpmalloweddeprecatedversions

@mcmxcdev
Copy link
Contributor

Yeah, I can recommend muting the indirect dependency warnings with pnpm.allowedDeprecatedVersions. Even better, you open an issue in that dependencies repository to ask them nicely to get rid of that dependency.

I have opened a similar issue to this in #5951 which would make pnpm.allowedDeprecatedVersions more user-friendly. In the issue, you can see how we use that pnpm feature.

@Dzieni
Copy link

Dzieni commented Sep 19, 2023

Show the path of depdencies to the package that's being warned about and a link to the repo of the package importing the deprecated dependency. This at least informs users why the warning is happening and gives them a pointer to where they can contribute or request a fix.

@zkochan what about this part of the issue? I'm fighting with deprecated subdeps and this kind of message would be super helpful :)

@zkochan
Copy link
Member

zkochan commented Sep 19, 2023

You can run pnpm why <pkg> to find what requires the deprecated package.

a link to the repo of the package importing the deprecated dependency. This at least informs users why the warning is happening and gives them a pointer to where they can contribute or request a fix.

I don't think this is necessary. The real fix is to update the dependencies in most cases.

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

Successfully merging a pull request may close this issue.

4 participants