cargo clean: Add target directory validation#16712
cargo clean: Add target directory validation#16712TanmayArya-1p wants to merge 2 commits intorust-lang:masterfrom
Conversation
|
I also noticed that if a file path is passed via |
|
r? @weihanglo rustbot has assigned @weihanglo. Use Why was this reviewer chosen?The reviewer was selected based on:
|
94c1489 to
94a4d66
Compare
|
thanks for the review :) Also I noticed that the CI keeps failing in something totally unrelated. I see it's happening in other PRs as well. Any idea why this is happening? |
Feel free to rebase onto master! |
94a4d66 to
c6cdaa1
Compare
This comment has been minimized.
This comment has been minimized.
f72fbd1 to
23c225b
Compare
|
Added a check(and test) to make sure |
This comment was marked as duplicate.
This comment was marked as duplicate.
|
I knew we discussed this during a meeting last year, but for a behavior change it is still better to have a formal record and give members time to think about it offline. Hence @rfcbot fcp merge cargo This implements the target-dir validation described in #9192 (comment).
|
|
Team member @weihanglo has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
From #9192 (comment)
What led to deciding in the direction of the future-incompat warning? |
For myself, to be conservative. I remembered rust-analyzer may create target-dir before running any |
|
@TanmayArya-1p While this is still in FCP, we were discussing whether the target-dir-is-file check can be a separate commit, or even a separate PR. That one turns out to be less controversial within the Cargo team. |
|
cool, i'll open another pr for the file validation. |
As discussed in #16712 , this is a separate PR that adds validation to `cargo clean` to make sure target-dir is not a file #### Tests: - Added unit tests for when target-dir is found to be a file. - I also noticed that there was no unit test asserting the expected behaviour discussed in <#7510 (comment)> when the target-dir is a symlink. I added a unit test that asserts that when the target-dir is a symlink, cargo should just delete the symlink and should not delete the content it is pointing to.
This comment has been minimized.
This comment has been minimized.
23c225b to
53f4b78
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
The choice when we last discussed this wasn't between future-incompat OR error but do-nothing OR future-incompat. |
I was re-reading #9192 (comment) and the meeting note. My understanding is that, for the env/config cases, the conclusion was not to hard-error right away. Instead the direction was to use a future-incompat warning first and then revisit based on user feedback. I wasn't in the meeting, though I feel like without a warning there is no action we can take in the future. The drawback of the warning is no way to suppress it though. |
There was a problem hiding this comment.
Do we need to consider the new build directory layout here? I am not sure if this is out of scope. However, for the new build dir layout, I believe cargo clean also deletes the build directory. Should we perform the same check for the build directory?
Even if it is out of scope, it may be better to create an issue to track it if necessary.
I think that seems reasonable to also check the
The validation performed by |
Either in this or a separate PR is fine for me, though I would suggest doing it after the FCP concludes |
What does this PR try to resolve?
Fixes #9192
Implements the checks mentioned in this comment
To summarise, when
cargo cleanis run with a specified target directory:--target-dir: check if a validCACHEDIR.TAGexists in the target directory and hard error otherwise.CACHEDIR.TAGTests
I've added 3 sets of unit tests for:
--target-diris used explicitlyCARGO_TARGET_DIRenv variableLet me know if there is a case I've missed or if i need to merge multiple tests into a single one.