the-lean-crate / cargo-diet

A cargo-companion to become a 'lean crate' (a member of The Lean Crate Initiative)
https://github.com/the-lean-crate/criner
MIT License
154 stars 3 forks source link

Toml parsing fails for `.workspace` keys #9

Closed hecatia-elegua closed 1 year ago

hecatia-elegua commented 1 year ago

First of all, thank you for this! I was surprised examples and tests do not get cut out automatically on cargo publish. Is there any downside to removing them? iirc someone mentioned package managers which like to run those tests first or some other obscure thing?

image might be due to an older toml version parser

workaround: version = { workspace = true } for all dotted keys

Byron commented 1 year ago

Thanks for letting me know!

It looks like the toml parser used here is very old: toml_edit matches 0.2.1; latest is 0.19.8, and upgrading isn't trivial as the API changed quite a bit.

I will see when I get to it but would appreciate help.

I was surprised examples and tests do not get cut out automatically on cargo publish. Is there any downside to removing them? iirc someone mentioned package managers which like to run those tests first or some other obscure thing?

cargo publish publishes everything in the directory that isn't ignored by git, which can lead to huge packages. This approach seems safe even though it may lead to surprises as well. That's the reason for cargo-diet existing, and I can say that it makes choices and is opinionated. Probably the need for opinion is why cargo tooling can't do it to that extend, but it's a guess.

Thanks for also mentioning the workaround as well, let me repeat it here.

Workaround

Use version = { workspace = true } instead of version.workspace = true