diff --git a/src/bin/cargo/commands/install.rs b/src/bin/cargo/commands/install.rs index 4275aa70075..b51c021f567 100644 --- a/src/bin/cargo/commands/install.rs +++ b/src/bin/cargo/commands/install.rs @@ -9,6 +9,7 @@ use cargo::util::IntoUrl; use cargo::util::ToSemver; use cargo::util::VersionReqExt; use cargo::CargoResult; +use itertools::Itertools; use semver::VersionReq; use cargo_util::paths; @@ -119,6 +120,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { .get_many::("crate") .unwrap_or_default() .cloned() + .dedup_by(|x, y| x == y) .map(|(krate, local_version)| resolve_crate(krate, local_version, version)) .collect::>>()?; diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index 0da4a57cc27..fd53b607bf3 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -57,6 +57,28 @@ fn simple() { assert_has_not_installed_exe(cargo_home(), "foo"); } +#[cargo_test] +fn install_the_same_version_twice() { + pkg("foo", "0.0.1"); + + cargo_process("install foo foo") + .with_stderr( + "\ +[UPDATING] `[..]` index +[DOWNLOADING] crates ... +[DOWNLOADED] foo v0.0.1 (registry [..]) +[INSTALLING] foo v0.0.1 +[COMPILING] foo v0.0.1 +[FINISHED] release [optimized] target(s) in [..] +[INSTALLING] [CWD]/home/.cargo/bin/foo[EXE] +[INSTALLED] package `foo v0.0.1` (executable `foo[EXE]`) +[WARNING] be sure to add `[..]` to your PATH to be able to run the installed binaries +", + ) + .run(); + assert_has_installed_exe(cargo_home(), "foo"); +} + #[cargo_test] fn toolchain() { pkg("foo", "0.0.1");