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

workspace-duplicates is oversensitive for intra-workspace path-only dependencies #682

Closed
adam-azarchs opened this issue Jul 27, 2024 · 2 comments · Fixed by #685
Closed
Labels
enhancement New feature or request

Comments

@adam-azarchs
Copy link

Is your feature request related to a problem? Please describe.
We have a monorepo with a large number of crates in the workspace. We use workspace dependencies for external dependencies, so we really like the workspace-duplicates warning, but it's a bit pedantic and arguably not even desirable when it complains about path dependencies between different crates in the workspace.

Describe the solution you'd like

Do not trigger workspace-duplicates if all of the following are true:

  1. The dependency is specified only by path (as opposed to path + version or git target. This necessarily means the referencing crate cannot be published to a registry)
  2. The path is to another crate in the same workspace.
  3. The target crate is private (publish = false).

In that situation, it is unlikely that the crate would ever be referred to by anything other than path, so adding an entry in the workspace-level Cargo.toml is kind of pointless.

Describe alternatives you've considered

Adding a configuration option for workspace-duplicates to ignore path-only dependencies. This would simplify the analysis above, as only the first criteria would need to be evaluated.

@adam-azarchs adam-azarchs added the enhancement New feature or request label Jul 27, 2024
@Jake-Shadle
Copy link
Member

Why would it be pointless? That would mean that every dependency declaration would need to use the full relative path making it tedious to move/rename. But I'll add an option.

@adam-azarchs
Copy link
Author

adam-azarchs commented Jul 28, 2024

At least in our workspace, the crate directories are all direct descendants of the workspace directory, so the warnings end up looking like

warning[workspace-duplicate]: crate foo = 0.1.0 is used 6 times in the workspace, and there was no shared workspace dependency for it
   ┌─ /.../xxx/Cargo.toml:80:1
   │
80 │ foo = { path = "../foo" }
   │ ────────────────
   │
   ┌─ /.../xxx/Cargo.toml:61:1
   │
61 │ foo = { path = "../foo" }
   │ ────────────────
   │
   ┌─ /.../xxx/Cargo.toml:35:1
   │
35 │ foo = { path = "../foo" }
   │ ────────────────
   │
   ┌─ /.../xxx/Cargo.toml:19:1
   │
19 │ foo= { path = "../foo" }
   │ ────────────────
   │
   ┌─ /.../xxx/Cargo.toml:41:1
   │
41 │ foo = { path = "../foo" }
   │ ────────────────
   │
   ┌─ /.../xxx/Cargo.toml:39:1
   │
39 │ foo = { path = "../foo" }

Except multiply that by a couple of dozen values of foo. workspace = true wouldn't really be any more concise or maintainable, and certainly less immediately obvious to a reader that the dependency is repository-local. Adding a couple of dozen additional lines to the workspace Cargo.toml would in fact seem to be less maintainable.

Sure, "maybe don't put dozens of crates as sibling directories without any kind of organizing hierarchy" would have been good advice to give several years ago when this workspace was first set up, but here we are.

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

Successfully merging a pull request may close this issue.

2 participants