-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add the ability to rename a crate inherited from the workspace #12546
Comments
When renaming, in addition to the dependency name, you specify a package of a different name. What I'm not too sure about is taking the |
I mean, in the case of an inherited dependency, Cargo could use the Something like this: flowchart RL
subgraph Workspace
itoa-old -- "package = #quot;itoa#quot;" --> itoaN[itoa 0.4]
end
subgraph member-2
itoa -- "package = #quot;itoa-old#quot;" --> itoa-old
end
|
My concern is that that isn't the package's name in the workspace but a dependency's name and I feel a little uncomfortable co-mingling the two. |
It's not necessary to mingle the names, the problem is that you can't rename the crates at all, if you are trying to inherit them from the workspace. |
I have a related issue (I think). I have a bunch of crates in my workspace: # ./Cargo.toml
foo = { git = "https://github.com/awasome/qux", branch = "master" }
bar = { git = "https://github.com/awasome/qux", branch = "master" } Then in a crate:
But the current cargo won't accept this. I'm ready to having a try at this, if it's not too hard for a newcomer. I assume it's not, it's should be fairly simple to add, right? |
Yes, it may be simple, but I guess this change should've a better design. As was stated above, using the [dependencies]
itoa = { workspace = true, name = "itoa-old" } And @Boiethios, seems like |
Haven't thought this through but one idea [dependencies]
itoa = { workspace = "itoa-old" } |
This is what I tried without checking docs, assuming it works as expected. But it did not :( |
Can this solution be applied and merged? #12546 (comment) |
I can try to implement this, but someone from the team should approve this design first. |
Do you know who to ping from the design team? |
If you want to see the relevant team, it is here (yes, I'm on it). My idea was just for brainstorming purposes. People immediately jumped on it without giving it any critical thought. That critical thought is what is needed to drive this forward. In thinking about this a bit more, I at least would first want to see what other needs we come up with for workspace inheritance to make sure we don't design ourselves into a corner, Here, we propose making Example future expansions that could possibly get in the way
I would also be interested in any thoughts from @Muscraft considering they've put a lot of thought into this since they worked on it. |
btw the obvious workaround for this is to just use the rename within your package (I assume that works) # member-2/Cargo.toml
[dependencies]
itoa-old.workspace = true For people pressing this, the most relevant information would be why the workaround is not sufficient in your specific case. |
Sorry, what workaround do you mean by rename within your package?
…On Tue, 17 Oct 2023, 03:11 Ed Page, ***@***.***> wrote:
btw the obvious workaround for this is to just use the rename within your
package (I assume that works)
# member-2/Cargo.toml
[dependencies]itoa-old.workspace = true
For people pressing this, the most relevant information would be why the
workaround is not sufficient in your specific case.
—
Reply to this email directly, view it on GitHub
<#12546 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA6JSVLZCTJK7FATQENCNA3X7U6BZAVCNFSM6AAAAAA34ADKKKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRUGU3TAMRTHE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Changes: - Pull all dependencies to the workspace and add a CI check. - Fixup the crates that had differing dependency aliases. - Add CI check to keep deps in the workspace - Add Taplo config for TOML formatting (follow up: add CI check) This is a preliminary to updating to the new SDK version as we currently use conflicting aliases for a few packages while packages are not able to rename workspace deps, see rust-lang/cargo#12546 This is a No-OP change, as can be verified with this: ```bash git checkout oty-fix-dependencies cargo tree -e features > oty.tree git checkout origin/main cargo tree -e features > main.tree diff main.tree oty.tree ``` - [x] Does not require a CHANGELOG entry --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: ordian <noreply@reusable.software>
Inherited workspace dependencies cannot be renamed by the crate using them (see [1](rust-lang/cargo#12546), [2](https://stackoverflow.com/questions/76792343/can-inherited-dependencies-in-rust-be-aliased-in-the-cargo-toml-file)). Since we want to use inherited workspace dependencies everywhere, we first need to unify all aliases that we use for a dependency throughout the workspace. The umbrella crate is currently excluded from this procedure, since it should be able to export the crates by their original name without much hassle. For example: one crate may alias `parity-scale-codec` to `codec`, while another crate does not alias it at all. After this change, all crates have to use `codec` as name. The problematic combinations were: - conflicting aliases: most crates aliases as `A` but some use `B`. - missing alias: most of the crates alias a dep but some dont. - superfluous alias: most crates dont alias a dep but some do. The script that i used first determines whether most crates opted to alias a dependency or not. From that info it decides whether to use an alias or not. If it decided to use an alias, the most common one is used everywhere. To reproduce, i used [this](https://github.com/ggwpez/substrate-scripts/blob/master/uniform-crate-alias.py) python script in combination with [this](https://github.com/ggwpez/zepter/blob/38ad10585fe98a5a86c1d2369738bc763a77057b/renames.json) error output from Zepter. --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de>
Inherited workspace dependencies cannot be renamed by the crate using them (see [1](rust-lang/cargo#12546), [2](https://stackoverflow.com/questions/76792343/can-inherited-dependencies-in-rust-be-aliased-in-the-cargo-toml-file)). Since we want to use inherited workspace dependencies everywhere, we first need to unify all aliases that we use for a dependency throughout the workspace. The umbrella crate is currently excluded from this procedure, since it should be able to export the crates by their original name without much hassle. For example: one crate may alias `parity-scale-codec` to `codec`, while another crate does not alias it at all. After this change, all crates have to use `codec` as name. The problematic combinations were: - conflicting aliases: most crates aliases as `A` but some use `B`. - missing alias: most of the crates alias a dep but some dont. - superfluous alias: most crates dont alias a dep but some do. The script that i used first determines whether most crates opted to alias a dependency or not. From that info it decides whether to use an alias or not. If it decided to use an alias, the most common one is used everywhere. To reproduce, i used [this](https://github.com/ggwpez/substrate-scripts/blob/master/uniform-crate-alias.py) python script in combination with [this](https://github.com/ggwpez/zepter/blob/38ad10585fe98a5a86c1d2369738bc763a77057b/renames.json) error output from Zepter. --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de>
Problem
Consider the following part with workspace dependencies from root
Cargo.toml
:And parts with dependencies from 2 workspace members:
Before checking/compiling
member-2
, Cargo prints this warning:And hence ignores the
package
key frommember-2
'sCargo.toml
.So, unless I missed something in the documentation, Cargo can't rename dependencies inherited from the workspace.
Proposed Solution
Make Cargo read the
package
key in inherited dependencies, and rename them as it does with usual dependencies.Notes
No response
The text was updated successfully, but these errors were encountered: