-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
cargo clean ate my entire project #8866
Comments
I have the same bug report (although fortunately I didn't run cargo clean). |
Re the CACHEDIR.TAG point, will any non-clean cargo command just put it into the root of your project if you have set A better check would IMO be whether any of the the files to be deleted are tracked by git, and if so, bail out with an error. Cargo publish IIRC already has a similar mode. |
@est31 sure, a sanity check for |
@jyn514 that has some dangerous implications when multiple cargo versions use the same project. I think if that's done, one should at least emit errors for a while, say a few months to a year, and then switch the behaviour. |
I don't understand what the dangerous implications would be. Target directories aren't ever shared across toolchain versions AFAIK. |
@jyn514 well someone just complained that having |
the cachedir.tag point is kinda moot, thinking about it. a previous build would create it (unless it checks for the directory being empty) |
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
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
:(
The text was updated successfully, but these errors were encountered: