cargo package --allow-dirty
fails for not recognizing deleted un-staged files in git repo
#9580
Labels
cargo package --allow-dirty
fails for not recognizing deleted un-staged files in git repo
#9580
Problem
My workflow has a command alias that includes build, test and packaging steps in one run. During recent work, a weird issue was discovered that a file deletion would cause such workflow to fail. It was later found
cargo package --allow-drity
would fail forNo such file or directory (os error 2)
when deleted file is not yet staged in the git repo, andcargo package
would still show the file deleted in the list. The issue would be fixed by agit add .
command to stage all local changes (no commit needed).Expecting the deleted files would not fail a
cargo package --allow-dirty
run, for better and faster local change testing on every workflow steps, and not getting developers running into weird issue when forgetting file stagingSteps
cargo new --vcs git --bin cargo-git-test
cargo run
: successgit status
: all files untracked/unstagedcargo package
: fail for files not committed (expected behavior)cargo package --allow-dirty
: success and all files recognizedgit add . && git commit -m "first commit"
. Expect no behavior change after the first commit (despitecargo package
would not complain about uncommitted changes)lib.rs
and makemain.rs
buildable:cargo run
: success, output should indicate the updated print stringcargo package
: fail as expected, but still referring to the deleted filecargo package --allow-dirty
: fail withNo such file or directory (os error 2)
git add .
(no commit needed), andcargo package --allow-dirty
would pass, withcargo package
no longer show the deleted file in list.Possible Solution(s)
It seems like
cargo package
command would hold a stale list of files when git repository is not staged. It would refer to the real file content so when all files still exist it would not have issue. But when files are deleted, it would fail by trying to refer them in the stale list. It is possible to fix this by treating deleted files specially or ignoring unfound files (but also would need to fail in case of unanticipated file system change to prevent an FP packaging success......)Notes
Output of
cargo version
:cargo 1.52.0 (69767412a 2021-04-21)
Have tested the issue on different Linux distributions and it appears the same. The reproducing steps was performed in following environment after fresh installation:
The text was updated successfully, but these errors were encountered: