From: mseri Date: Wed, 26 Aug 2015 14:37:07 +0000 (+0100) Subject: Fix for issue #1942 'cargo run fails if called from executable folder' X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~17^2~93^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=99aa55df4150c2c00741581065be34cca33357dc;p=cargo.git Fix for issue #1942 'cargo run fails if called from executable folder' It maybe a hacky way but I think that changing `util::without_prefix` is a bad approach. Maybe modify `process.build_command` could be another possible approach. --- diff --git a/src/cargo/ops/cargo_run.rs b/src/cargo/ops/cargo_run.rs index 79bd505c5..6b9d285d7 100644 --- a/src/cargo/ops/cargo_run.rs +++ b/src/cargo/ops/cargo_run.rs @@ -48,7 +48,9 @@ pub fn run(manifest_path: &Path, let compile = try!(ops::compile(manifest_path, options)); let exe = &compile.binaries[0]; let exe = match util::without_prefix(&exe, config.cwd()) { - Some(path) => path, + Some(path) => if path.as_os_str() == path.file_name().unwrap() { &**exe } + else { path }, // workaround for being able to use + // `cargo run` from the executable path itself None => &**exe, }; let mut process = try!(compile.target_process(exe, &root))