Problem
Since #16712 trying to run cargo clean with a custom target dir fails if the target dir is non-existent rather than behaving like a nop.
Steps
rm foo || true
cargo clean --target-dir foo
- The following error is produced
error: cannot clean `/home/bjorn/cg_clif/foo`: missing or invalid `CACHEDIR.TAG` file
|
= note: cleaning has been aborted to prevent accidental deletion of unrelated files
or alternatively
cargo check --target-dir foo
cargo clean --target-dir foo passes
cargo clean --target-dir foo fails
Possible Solution(s)
Do nothing when the target dir already doesn't exist.
Notes
No response
Version
cargo 1.97.0-nightly (7ecf0285e 2026-04-18)
release: 1.97.0-nightly
commit-hash: 7ecf0285ebb408d596e4a8ac76a0980d8edb7005
commit-date: 2026-04-18
host: x86_64-unknown-linux-gnu
libgit2: 1.9.2 (sys:0.20.4 vendored)
libcurl: 8.19.0-DEV (sys:0.4.87+curl-8.19.0 vendored ssl:OpenSSL/3.5.4)
ssl: OpenSSL 3.5.4 30 Sep 2025
os: Arch Linux [64-bit]
Problem
Since #16712 trying to run
cargo cleanwith a custom target dir fails if the target dir is non-existent rather than behaving like a nop.Steps
rm foo || truecargo clean --target-dir fooor alternatively
cargo check --target-dir foocargo clean --target-dir foopassescargo clean --target-dir foofailsPossible Solution(s)
Do nothing when the target dir already doesn't exist.
Notes
No response
Version