Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
badboy opened this issue Nov 4, 2020 · 2 comments
Closed

Comments

@badboy
Copy link

badboy commented Nov 4, 2020

This bug still exists in rust-script: DanielKeep/cargo-script#57

Copied:

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.


(Paths/Invocations should be adjusted for rust-script of course)

@fornwall
Copy link
Owner

fornwall commented Nov 4, 2020

Thanks a lot for reporting!

This has now been fixed in version 0.9.0 - update with cargo install --force rust-script.

To fix existing scripts you need to run rust-script --clear-cache once after updating, to purge the incorrectly cached executable paths.

@badboy
Copy link
Author

badboy commented Nov 4, 2020

Thanks! That was quick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants