Skip to content

Commit fcc3786

Browse files
committed
Auto merge of #12868 - hi-rustin:rustin-patch-install, r=weihanglo
Remove duplicate binaries during install
2 parents f327dbd + 731ae05 commit fcc3786

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/bin/cargo/commands/install.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use cargo::util::IntoUrl;
99
use cargo::util::ToSemver;
1010
use cargo::util::VersionReqExt;
1111
use cargo::CargoResult;
12+
use itertools::Itertools;
1213
use semver::VersionReq;
1314

1415
use cargo_util::paths;
@@ -119,6 +120,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
119120
.get_many::<CrateVersion>("crate")
120121
.unwrap_or_default()
121122
.cloned()
123+
.dedup_by(|x, y| x == y)
122124
.map(|(krate, local_version)| resolve_crate(krate, local_version, version))
123125
.collect::<crate::CargoResult<Vec<_>>>()?;
124126

tests/testsuite/install.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,28 @@ fn simple() {
5757
assert_has_not_installed_exe(cargo_home(), "foo");
5858
}
5959

60+
#[cargo_test]
61+
fn install_the_same_version_twice() {
62+
pkg("foo", "0.0.1");
63+
64+
cargo_process("install foo foo")
65+
.with_stderr(
66+
"\
67+
[UPDATING] `[..]` index
68+
[DOWNLOADING] crates ...
69+
[DOWNLOADED] foo v0.0.1 (registry [..])
70+
[INSTALLING] foo v0.0.1
71+
[COMPILING] foo v0.0.1
72+
[FINISHED] release [optimized] target(s) in [..]
73+
[INSTALLING] [CWD]/home/.cargo/bin/foo[EXE]
74+
[INSTALLED] package `foo v0.0.1` (executable `foo[EXE]`)
75+
[WARNING] be sure to add `[..]` to your PATH to be able to run the installed binaries
76+
",
77+
)
78+
.run();
79+
assert_has_installed_exe(cargo_home(), "foo");
80+
}
81+
6082
#[cargo_test]
6183
fn toolchain() {
6284
pkg("foo", "0.0.1");

0 commit comments

Comments
 (0)