Skip to content

Fix issue with --clear-cache when "projects" directory doesn't exist #152

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DownD
Copy link

@DownD DownD commented May 13, 2025

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).

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

Successfully merging this pull request may close these issues.

1 participant