diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 96a739ac68d..d8c8711b376 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -63,10 +63,10 @@ pub fn install(root: Option<&str>, let root = resolve_root(root, opts.config)?; let map = SourceConfigMap::new(opts.config)?; - let installed_anything = if krates.len() <= 1 { + let (installed_anything, scheduled_error) = if krates.len() <= 1 { install_one(root.clone(), map, krates.into_iter().next(), source_id, vers, opts, force, true)?; - true + (true, false) } else { let mut succeeded = vec![]; let mut failed = vec![]; @@ -95,7 +95,7 @@ pub fn install(root: Option<&str>, opts.config.shell().status("\nSummary:", summary.join(" "))?; } - !succeeded.is_empty() + (!succeeded.is_empty(), !failed.is_empty()) }; if installed_anything { @@ -114,6 +114,10 @@ pub fn install(root: Option<&str>, dst.display()))?; } + if scheduled_error { + bail!("some crates failed to install"); + } + Ok(()) } diff --git a/tests/install.rs b/tests/install.rs index bd4b20a63fc..9d385551b73 100644 --- a/tests/install.rs +++ b/tests/install.rs @@ -60,7 +60,7 @@ fn multiple_pkgs() { pkg("bar", "0.0.2"); assert_that(cargo_process("install").args(&["foo", "bar", "baz"]), - execs().with_status(0).with_stderr(&format!("\ + execs().with_status(101).with_stderr(&format!("\ [UPDATING] registry `[..]` [DOWNLOADING] foo v0.0.1 (registry file://[..]) [INSTALLING] foo v0.0.1 @@ -76,6 +76,7 @@ error: could not find `baz` in `registry [..]` Summary: Successfully installed foo, bar! Failed to install baz (see error(s) above). warning: be sure to add `[..]` to your PATH to be able to run the installed binaries +error: some crates failed to install ", home = cargo_home().display()))); assert_that(cargo_home(), has_installed_exe("foo"));