You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I declare a dependency that includes an underscore (_) in its name under [workspace.dependencies] in the manifest of my virtual workspace and then add that dependency to a member crate using cargo add, I get different results depending on how I invoke the command:
If I specify the dependency with an underscore, it is added to the member manifest as <dependency>.workspace = true
If I specify the dependency with a hyphen, it is translated but then added to the member manifest as <dependency> = "version"
Expected behavior: Since the dependencies are the same in both cases, I would expect both invocations to result in <dependency>.workspace = true.
It seems like Cargo compares the desired dependency to the dependencies listed in the workspace manifest at some point, to decide when to use <dependency>.workspace = true. It also seems like Cargo translates hyphens to underscores when appropriate. But perhaps the comparison happens before the translation, so we see this behavior (just my guess). If we reverse the order of those operations, then that should solve the issue.
It looks like a dup of #13702 and has already been fixed by #13765. The fix is available in latest nightly and targeted at 1.83 release. Close as resolved. Thank you.
Problem
When I declare a dependency that includes an underscore (
_
) in its name under[workspace.dependencies]
in the manifest of my virtual workspace and then add that dependency to a member crate usingcargo add
, I get different results depending on how I invoke the command:<dependency>.workspace = true
<dependency> = "version"
Expected behavior: Since the dependencies are the same in both cases, I would expect both invocations to result in
<dependency>.workspace = true
.Steps
Folder structure
Cargo.toml (workspace)
Cargo.toml (crate)
Possible Solution(s)
It seems like Cargo compares the desired dependency to the dependencies listed in the workspace manifest at some point, to decide when to use
<dependency>.workspace = true
. It also seems like Cargo translates hyphens to underscores when appropriate. But perhaps the comparison happens before the translation, so we see this behavior (just my guess). If we reverse the order of those operations, then that should solve the issue.Notes
No response
Version
cargo 1.76.0 (c84b367 2024-01-18)
release: 1.76.0
commit-hash: c84b367
commit-date: 2024-01-18
host: x86_64-apple-darwin
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 8.7.1 (sys:0.4.70+curl-8.5.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1w 11 Sep 2023
os: Mac OS 14.6.1 [64-bit]
The text was updated successfully, but these errors were encountered: