-
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 publish excludes files called target
#12790
Comments
Sadly naming the file to something else and then copying it over in |
Workaround for rust-lang/cargo#12790.
Thanks for the report. Haven't got time running the repro but I am guessing this piece of code is the culprit: cargo/src/cargo/sources/path.rs Lines 329 to 330 in 637ade0
It may need to verify if the In addition, there is no an official way to detect if a directory is target-dir. A relevant discussion can be found in #12441. |
Checking if it's a directory still leaves part of the issue, since it potentially still makes sense to have a resource directory called
Thinking about it some more, why is knowing the true target directory so hard? Is there anything wrong with this logic?
That line is another good candidate, I wonder why
I'm willing to give this issue a shot. I'll get started building cargo and seeing if I can figure out the exact cause, and then start writing a test for this. |
Finding the target directory can be challenging because its configurable, from call to call even. Another challenging part is that packages might not be in a workspace (or they might have not been in a workspace but now are). Most likely, the safest option is to only filter out Note that we have two code paths for enumerating source for a package. The one @weihanglo linked and cargo/src/cargo/sources/path.rs Line 448 in 637ade0
Two things about that check you linked
|
This seems to be the best solution so far. I will make a PR for it. @rustbot claim |
Problem
When publishing or packaging a crate that contains a file called
target
(different from the typical roottarget
folder), the file is not included. This happens even though thetarget
file is not ignored by either.gitignore
or.git/info/exclude
. It's also not a glob evaluation issue, this is still an issue if.gitignore
is completely empty.This also only happens if the
target
file is currently tracked in git. This is not that important by itself, but it might help figuring out what exactly causes the bug.Steps
I've made a repository to reproduce this bug: https://github.com/KarelPeeters/cargo_bug_package_target
The steps to follow:
note that
data/target
is missing, this is the main bug..git
entirelyNote that
data/target
is not missing anymore, this shows that the bug only happens for tracked files.Possible Solution(s)
I assume this is caused by some bad interaction in
build_ar_list
between theVCSInfo
stuff and the hardcoded check for a filename of"target"
here: https://github.com/rust-lang/cargo/blob/master/src/cargo/ops/cargo_package.rs#L934I'm not sure what much of the context there is trying to do, so I don't know what the right fix is.
One issue to keep in mind is that multiple crates that share a repository while not being a workspace can have multiple
target
folders. So a simple check like "only ignore the roottarget
directory" is also not good enough. There should be existing infrastructure to figure out what the realtarget
directory is though, sincecargo clean
(like many other subcommands) needs that.Notes
I noticed this when trying to vendor some cuda headers and associated files, which is neccesary to get docs.rs to build one of my crates correctly.
One of these files happens to be called
target
.Here it is in my github repository: https://github.com/KarelPeeters/Kyanite/tree/1eb40f2dde70d3432f218bfbaa5c7d37eebbd394/kn-cuda-sys/doc_headers/cuda_include/nv
But the same file is missing on docs.rs and crates.io: https://docs.rs/crate/kn-cuda-sys/0.4.1/source/doc_headers/cuda_include/nv/
Version
The text was updated successfully, but these errors were encountered: