-
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
Fix: Make path dependencies with the same name stays locked #13572
Conversation
c52a34e
to
c07cf47
Compare
@rustbot ready |
@ehuss any chance for some feedback? I'm not sure I'm doing the right thing. |
42fbaf5
to
3a580a4
Compare
src/cargo/core/resolver/encode.rs
Outdated
if let Some(source_id) = version_source.get(&pkg_version) { | ||
return Some(source_id); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still a little concerned about the behavior here when there are multiple versions, but none of them match. There are two concerns:
- This randomly chooses one of the packages, which is not great for consistency.
- Depending on what changed and which random package it picks, you can end up with two packages with the same SourceId.
I'm still wondering if it is appropriate to return None
here if there are multiple versions, but none of them match. For example, something like:
} | |
} | |
return None; |
Does that make sense?
Here is a test that illustrates the problem with having multiple versions: #[cargo_test]
fn same_name_version_changed() {
// Illustrates having two path packages with the same name, but different versions.
// Verifies it works correctly when one of the versions is changed.
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "1.0.0"
edition = "2021"
[dependencies]
foo2 = { path = "foo2", package = "foo" }
"#,
)
.file("src/lib.rs", "")
.file(
"foo2/Cargo.toml",
r#"
[package]
name = "foo"
version = "2.0.0"
edition = "2021"
"#,
)
.file("foo2/src/lib.rs", "")
.build();
p.cargo("tree")
.with_stderr("[LOCKING] 2 packages to latest compatible versions")
.with_stdout(
"\
foo v1.0.0 ([ROOT]/foo)
└── foo v2.0.0 ([ROOT]/foo/foo2)
",
)
.run();
p.change_file(
"foo2/Cargo.toml",
r#"
[package]
name = "foo"
version = "2.0.1"
edition = "2021"
"#,
);
p.cargo("tree")
.with_stderr(
"\
[LOCKING] 1 package to latest compatible version
[ADDING] foo v2.0.1 ([ROOT]/foo/foo2)
",
)
.with_stdout(
"\
foo v1.0.0 ([ROOT]/foo)
└── foo v2.0.1 ([ROOT]/foo/foo2)
",
)
.run();
} With this PR as-is, this test will randomly fail. I'd recommend adding this test to the |
82a4a84
to
a726c53
Compare
Oh on, the ci faild due to
I guess this pr merge can solve this |
a726c53
to
ab92717
Compare
Thanks! I moved the suggested test to @bors r+ |
Fix: Make path dependencies with the same name stays locked ### What does this PR try to resolve? Fixes: #13405 This is a workround based on #13405 (comment) ### How should we test and review this PR? first commit will pass, second commit fixed it and update test. ### Additional information
💔 Test failed - checks-actions |
@bors retry |
☀️ Test successful - checks-actions |
Update cargo 9 commits in 0de7f2ec6c39d68022e6b97a39559d2f4dbf3930..84dc5dc11a9007a08f27170454da6097265e510e 2024-05-17 16:54:54 +0000 to 2024-05-20 18:57:08 +0000 - Fix warning about unused Permissions (rust-lang/cargo#13938) - fix: support IPv6-only network for cargo fix (rust-lang/cargo#13907) - Load `libsecret` by its `SONAME`, `libsecret-1.so.0` (rust-lang/cargo#13927) - docs(ref): Simplify check-cfg build.rs docs (rust-lang/cargo#13937) - Make `git::use_the_cli` test truly locale independent (rust-lang/cargo#13935) - Silence warnings running embedded unittests. (rust-lang/cargo#13929) - Fix warning output in build_with_symlink_to_path_dependency_with_build_script_in_git (rust-lang/cargo#13930) - Fix: Make path dependencies with the same name stays locked (rust-lang/cargo#13572) - Temporarily fix standard_lib tests on linux. (rust-lang/cargo#13931) r? ghost
Update cargo 9 commits in 0de7f2ec6c39d68022e6b97a39559d2f4dbf3930..84dc5dc11a9007a08f27170454da6097265e510e 2024-05-17 16:54:54 +0000 to 2024-05-20 18:57:08 +0000 - Fix warning about unused Permissions (rust-lang/cargo#13938) - fix: support IPv6-only network for cargo fix (rust-lang/cargo#13907) - Load `libsecret` by its `SONAME`, `libsecret-1.so.0` (rust-lang/cargo#13927) - docs(ref): Simplify check-cfg build.rs docs (rust-lang/cargo#13937) - Make `git::use_the_cli` test truly locale independent (rust-lang/cargo#13935) - Silence warnings running embedded unittests. (rust-lang/cargo#13929) - Fix warning output in build_with_symlink_to_path_dependency_with_build_script_in_git (rust-lang/cargo#13930) - Fix: Make path dependencies with the same name stays locked (rust-lang/cargo#13572) - Temporarily fix standard_lib tests on linux. (rust-lang/cargo#13931) r? ghost
What does this PR try to resolve?
Fixes: #13405
This is a workround based on #13405 (comment)
How should we test and review this PR?
first commit will pass, second commit fixed it and update test.
Additional information