From 9f0fa249b5d307bd97c8c4957a98ad9f47116bf9 Mon Sep 17 00:00:00 2001 From: Gleb Kozyrev Date: Sun, 1 May 2016 02:46:41 +0300 Subject: [PATCH] cargo-install: move binaries from the build dir if possible Try moving the binaries (and fall back to copying) if the build directory is a temporary one (source isn't a local path). --- src/cargo/ops/cargo_install.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 237f3aba957..d3d894e2378 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -131,6 +131,12 @@ pub fn install(root: Option<&str>, let staging_dir = try!(TempDir::new_in(&dst, "cargo-install")); for &(bin, src) in binaries.iter() { let dst = staging_dir.path().join(bin); + // Try to move if `target_dir` is transient. + if !source_id.is_path() { + if fs::rename(src, &dst).is_ok() { + continue + } + } try!(fs::copy(src, &dst).chain_error(|| { human(format!("failed to copy `{}` to `{}`", src.display(), dst.display()))