cargo: Cargo package says the repo is dirty, but the files are gitignored
Problem
I have a folder called “extra” that is in my .gitignore. git status confirms it
Cargo package says the repo is dirty, but those files are gitignored.
Note: In my Cargo.toml I am adding this extra folder to the include field, because i want this folder present in the package (but not in git).
Steps
- Add a folder with some data to the .gitignore
- Include that folder in the cargo package using the
includefield in the Cargo.toml
Possible Solution(s)
No response
Notes
Normally I worked around the bug with “–allow-dirty”, but now that i’ve switched to cargo release to publish my workspace, I cannot (it doesn’t support that flag)
Version
cargo version --verbose
cargo 1.70.0 (ec8a8a0ca 2023-04-25)
release: 1.70.0
commit-hash: ec8a8a0cabb0e0cadef58902470f6c7ee7868bdc
commit-date: 2023-04-25
host: aarch64-apple-darwin
libgit2: 1.6.3 (sys:0.17.0 vendored)
libcurl: 7.87.0 (sys:0.4.61+curl-8.0.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 13.3.0 [64-bit]
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 21 (11 by maintainers)
I tried that out, but it didn’t fix the problem. From reading the Cargo book, it seems that once
includeis specified,.gitignoreis no longer relevant.The behaviour of
cargo publishhere is desired, even though it might lack refinement for this case: a file is ignored by git and not tracked bygityet - in this case it could probably just be added to the package anyway. Maybe there is a test for that as well and I didn’t see it. Maybe this is something that could be improved when porting this area over togitoxide, then I should have a better understanding of the tests as well and how it should work in detail.Speaking only for
cargo-smart-release, it doesn’t try to re-implement any ignore logic but relies completely oncargo package- doing agit statuscheck is merely for convenience, and for that it only relies ongititself without extra logic so I think it’s fine in this case.I figured out the issue. My Cargo.toml had the line
include = ["src/**/*", "LICENSE", "README.md"]. The.direnvdirectory contains files calledLICENSEandREADME.md, which are the uncommitted files cargo was complaining about. Prefixing those file names with a/in Cargo.toml makes cargo happy.No,
cargo package --liststill complains with either variation.