Fix issue with --clear-cache when "projects" directory doesn't exist #152
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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).