Skip to content
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 ignores include section and fails when submodule (maybe just subdirectory) contains a Cargo.toml #8597

Open
yaahc opened this issue Aug 7, 2020 · 4 comments
Labels
C-bug Category: bug Command-package Command-publish S-triage Status: This issue is waiting on initial triage.

Comments

@yaahc
Copy link
Member

yaahc commented Aug 7, 2020

Problem

I'm trying to publish https://github.com/ZcashFoundation/zcashconsensus which compiles and re-exports a c++ library as a rust crate. This library is defined in another repository we do not control and we just include it as a git submodule. However, when attempting to publish the build.rs file fails because the c++ files it needs to build aren't pulled in with the rest of the files before packaging.

I tried to fix this by explicitly specifying an include list in the [package] section of my Cargo.toml but cargo seems to completely ignore the include section for files in the git submodule. I believe this is the same issue as seen in this older issue #2657

However, I cannot fix this the same way they did because the way brson fixed the issue was by using a previous version of cargo from before the feature to filter out files in subdirectories was introduced, and presumably such a version of cargo is 4 years old now...

Steps

  1. checkout the zcashconsensus repo https://github.com/ZcashFoundation/zcashconsensus
  2. add the following include section to the Cargo.toml
include = [
    ".github/workflows/ci.yml",
    ".gitignore",
    ".gitmodules",
    "Cargo.toml",
    "Cargo.toml.orig",
    "LICENSE",
    "README.md",
    "build.rs",
    "depend/check_uint128_t.c",
    "src/blake2b.rs",
    "src/lib.rs",
    "zcash/src/script/zcashconsensus.h"
]
  1. run cargo package --list --allow-dirty to show that the "zcash/src/script/zcashconsensus.h" file has not been included.

Notes

Output of cargo version:

❯ cargo version
cargo 1.45.0 (744bd1f 2020-06-15)

@scouten
Copy link

scouten commented Sep 1, 2020

Following: I'm encountering what appears to be a similar issue.

@yaahc
Copy link
Member Author

yaahc commented Sep 1, 2020

@scouten fwiw I ended up fixing this by removing the Cargo.toml in the subdirectory that was causing cargo to filter out all files from that directory.

@scouten
Copy link

scouten commented Sep 2, 2020

@yaahc thanks. In my case, it turned out to be a false alarm. It looked like the dir wasn't there, but in fact it was an unrelated issue.

@emilio
Copy link

emilio commented Dec 26, 2020

#9017 is another instance of this.

Abestanis added a commit to Abestanis/embed-rust that referenced this issue Aug 4, 2023
This wasn't really working, the compile succeeded during cargo publish
but the sources are still not included in the crate.
This is because cargo ignores all subdirectories with a Cargo.toml file:
rust-lang/cargo#8597
@epage epage added the S-triage Status: This issue is waiting on initial triage. label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug Command-package Command-publish S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

5 participants