DanielKeep / cargo-script

Cargo script subcommand
Other
729 stars 37 forks source link

exe_path is wrong when the script name matches the name of a dependency #57

Open Flakebi opened 6 years ago

Flakebi commented 6 years ago

Can be reproduced with the following script:

Filename: time.rs

#!/usr/bin/env run-cargo-script
// cargo-deps: chrono
extern crate chrono;
fn main() {
    println!("Hello");
}

When trying to execute with ./time.rs or cargo script time.rs, it fails with internal error: Permission denied (os error 13) because it tries to run /home/user/.cargo/binary-cache/release/deps/libtime-2d0d7bb318809c2f.rlib instead of .cargo/binary-cache/release/time.

Some time ago, this worked. I’d guess the error lies in cargo_target_by_message, picking the wrong line because the target.name is the same as the package name.

Workaround: Renaming the script to another name lets it run fine.

uberjay commented 5 years ago

Thanks for filing this issue... because wow was that confusing!

TheButlah commented 4 years ago

Still an issue - I had a script called bindgen.rs and a dependency on bindgen... I got that exact os error.