Skip to content

cargo clean ate my entire project #8866

Closed
@djugei

Description

@djugei

Problem
cargo clean ate my entire project

i entered cargo clean and expected the target directory to be gone. my project was gone instead.

Steps
set cargo target dir to nothing, for example by executing

export CARGO_TARGET_DIR=

because you don't know bash and thought thats how you clear environment variables.

then run cargo clean on something you don't care about, like for example the thing you have been working on for the last while and only have a 10 days old backup of.

Possible Solution(s)
cargo clean should not behave like rm -rf, but at most like rm -r, not deleting .git and stuff without warning even on incorrect configuration.

another option would be to only delete directories/directory trees that have the CACHEDIR.TAG that cargo already helpfully creates to mark the directory as being a cache directory that can be deleted without ill consequences.

Notes
:(

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions