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

Allow manifest dependencies of same-workspace crates to use workspace = true #13453

Open
CinchBlue opened this issue Feb 16, 2024 · 4 comments
Open
Labels
A-manifest Area: Cargo.toml issues A-workspace-inheritance Area: workspace inheritance RFC 2906 C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-team-input Status: Needs input from team on whether/how to proceed.

Comments

@CinchBlue
Copy link

CinchBlue commented Feb 16, 2024

Problem

I have 100+ workspace crates. In order for any of them to use each other, they need to use relative path.
It would be nice to just use:

[dependencies]
my-crate.workspace = true

for in-workspace crates when referring to other same-workspace dependencies. That way, I can move crates around + rename crates easily without having to edit every manifest that uses it in the workspace.

Proposed Solution

It should theoretically be possible without any surface changes at the manifest level. Each workspace crate has a canonical name, and alias could be handled through some additional spec field.

Notes

No response

@CinchBlue CinchBlue added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Feb 16, 2024
@CinchBlue CinchBlue changed the title Allow manifest dependencies of workspace crates to use workspace = true Allow manifest dependencies of same-workspace crates to use workspace = true Feb 16, 2024
@epage epage added A-manifest Area: Cargo.toml issues A-workspace-inheritance Area: workspace inheritance RFC 2906 labels Feb 16, 2024
@epage
Copy link
Contributor

epage commented Feb 16, 2024

The original RFC took a different approach, making version implicit if path is used, see https://github.com/rust-lang/rfcs/blob/master/text/2906-cargo-workspace-deduplicate.md#no-longer-need-both-version-and-path-to-publish-to-cratesio

This was rejected during stabilization which had some complications. I suspect this will run into some of the same. Not knowing what version you intend to use when publishing can get complicated.

If we limited the design to path dependencies only, that helps but that leaves off a good segment of users.

@CinchBlue
Copy link
Author

I suspect this will run into some of the same. Not knowing what version you intend to use when publishing can get complicated.

Then can't we alter publishing? This doesn't seem impossible, but it is indeed complicated. Where to start?

If we limited the design to path dependencies only, that helps but that leaves off a good segment of users.

What are other cases? I don't understand.

@epage
Copy link
Contributor

epage commented Feb 19, 2024

Then can't we alter publishing? This doesn't seem impossible, but it is indeed complicated. Where to start?

We'd need to do so in a way that is backwards compatible and where the solution is not worse than the problem.

The cargo team is limited in its bandwidth for efforts it can shepherd. For myself I can't commit to helping in driving this process. For an idea of what we are working on instead, see https://blog.rust-lang.org/inside-rust/2024/02/13/this-development-cycle-in-cargo-1-77.html

What are other cases? I don't understand.

The big problem is when you want publish a package with a path dependency. In that case, you need to specify the version field for when its published.

If we make these implicit dependencies only exist with path dependencies, and not version dependencies, then we avoid a lot of the problems but then we make this only work for internal packages.

@epage epage added S-needs-team-input Status: Needs input from team on whether/how to proceed. and removed S-triage Status: This issue is waiting on initial triage. labels Mar 7, 2024
@epage
Copy link
Contributor

epage commented Aug 13, 2024

This came up in conversation. In designing this, we'd need to decide how each field field gets set

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-manifest Area: Cargo.toml issues A-workspace-inheritance Area: workspace inheritance RFC 2906 C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-team-input Status: Needs input from team on whether/how to proceed.
Projects
None yet
Development

No branches or pull requests

2 participants