rust-script
rust-script copied to clipboard
Fix issue with --clear-cache when "projects" directory doesn't exist
When running rust-script with --clear-cache and the projects cache directory doesn't exist, an error will be thrown without running the underlaying script.
RUST_LOG=info rust-script --clear-cache scripts/generate_docs_api_spec.rs
[2025-05-13T13:25:25Z INFO rust_script] Arguments: Args { script: Some("scripts/generate_docs_api_spec.rs"), script_args: [], expr: false, loop_: false, count: false, base_path: None, pkg_path: None, gen_pkg_only: false, cargo_output: false, clear_cache: true, debug: false, dep: [], extern_: [], force: false, unstable_features: [], build_kind: Normal, toolchain_version: None, wrapper: None }
[2025-05-13T13:25:25Z INFO rust_script] cleaning cache with max_age: 0
[2025-05-13T13:25:25Z INFO rust_script] max_age is 0, clearing binary cache...
[2025-05-13T13:25:25Z INFO rust_script] cutoff: 1747142725179 ms
error: No such file or directory (os error 2)
The issue can be replicated by running the following:
rm -r /home/$USER/.cache/rust-script/projects
rust-script --clear-cache scripts/<some_script.rs>
This means that it will also happen if --clear-cache is used in the first execution after installation.
I believe the natural behavior should be to ignore the error and proceed with the script execution (thus creating the cache folder).