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 fails to parse generated manifest at publish time when there are conditional features activated on an ignored dev-dependency #12964

Closed
lovasoa opened this issue Nov 12, 2023 · 4 comments
Labels
C-bug Category: bug Command-package S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review

Comments

@lovasoa
Copy link

lovasoa commented Nov 12, 2023

Problem

In cargo, it is possible to conditionally activate a feature on a dependency based on the main crate features, using the crate/feature syntax:

[features]
# Enables parallel processing support by enabling the "rayon" feature of jpeg-decoder.
parallel = ["jpeg-decoder/rayon"]

This works if jpeg-decoder is in the main [dependencies] section of Cargo.toml. However, if jpeg-decoder is in the [dev-dependencies] section, and it is not included at publish time (because path dev-dependencies are ignored, for instance), then it fails with the following error:

error: failed to verify package tarball

Caused by:
  failed to parse manifest at `.../Cargo.toml`

Caused by:
  feature `parallel` includes `jpeg-decoder/rayon`, but `jpeg-decoder` is not a dependency

It looks like cargo auto-generated a faulty Cargo.toml by removing the path dev dependency in the dev-dependencies section, but not removing it from the features section.

Steps

No response

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.73.0 (9c4383fb5 2023-08-26)
release: 1.73.0
commit-hash: 9c4383fb55986096b414d98125421ab87b5fd642
commit-date: 2023-08-26
host: x86_64-unknown-linux-gnu
libgit2: 1.6.4 (sys:0.17.2 vendored)
libcurl: 8.2.1-DEV (sys:0.4.65+curl-8.2.1 vendored ssl:OpenSSL/1.1.1u)
ssl: OpenSSL 1.1.1u  30 May 2023
os: Ubuntu 22.04 (jammy) [64-bit]
@lovasoa lovasoa added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Nov 12, 2023
lovasoa added a commit to lovasoa/sqlx-oldapi that referenced this issue Nov 12, 2023
@epage epage added Command-package S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review and removed S-triage Status: This issue is waiting on initial triage. labels Nov 13, 2023
@epage
Copy link
Contributor

epage commented Nov 13, 2023

We need to update prepare_for_publish to strip these feature activations when stripping dependencies.

@weihanglo
Copy link
Member

Seems like a duplicate of #12225? There is an open PR but gets stale.

@epage
Copy link
Contributor

epage commented Nov 15, 2023

Closing in favor of #12225. If there is a mistake and we should keep this open, let us know!

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2023
@lovasoa
Copy link
Author

lovasoa commented Nov 15, 2023

Yes, this was indeed a duplicate. Sorry.

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 S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review
Projects
None yet
Development

No branches or pull requests

3 participants