-
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
fix(package): Recognize and normalize cargo.toml
#12399
Conversation
Being a bit cautious about not turning this into an error since this is most likely because of case insensitive filesystems.
r? @weihanglo (rustbot has picked a reviewer for you, use r? to override) |
1d9fcb2
to
3166e5f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another case this does not address (though slightly changes) is when a Linux system has multiple cases of Cargo.toml
Will this cause problems for projects already having both Cargo.toml
and cargo.toml
? Should we examine existing packages on crates.io?
Apart from that, looks pretty good!
To keep things simple, especially in getting a `Hash` implementation correct, I'm leveraging `unicase` for case-insensitive comparisons which is an existing dependency and I've been using for years on other projects. This also opens the door for us to add cross-platform compatibility hazard warnings about multiple paths that would write to the same location on a case insensitive file system. I held off on that because I assume we would want rust-lang#12235 first. This does mean we can't test the "no manifest" case anymore because the one case (no pun intended) I knew of for hitting it is now gone.
To lazy to examine them so I took an approach for handling it. Thoughts? |
Hm... unicase seems overkill no? IIRC, cargo's special filenames are all ascii. |
I wrote this with an eye for portability hazards in the future. Unsure if filesystems are case insensitive by ascii or by unicode but thought I'd play it safe rather than people in the future building on the this work and not taking this into account. |
Sure but I mean, pure ascii filenames are the only ones that can be compared portably. What version of the Unicode spec does a filesystem use to do case-insensitive comparisons? Trick question! It could be using any version or its own weird case table. So the only portable thing would be to ask the filesystem, unless you stick to ascii only. |
@ChrisDenton to clarify, how much of your concern is with
|
Well I do prefer having fewer dependencies but that's only a minor concern. And I'm not against using The "correct" way to do this for arbitrary names outside of ascii is to try opening with the expected file name then comparing the canonical name of the opened file with the expected name. But I realise this might be more involved then is wanted here, especially considering cross-platform concerns. |
Thanks for the clarification. I've updated to ASCII comparisons. I kept |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, and thanks everybody here for helping review :)
[package] | ||
name = "foo" | ||
version = "0.0.1" | ||
authors = [] | ||
exclude = ["*.txt"] | ||
license = "MIT" | ||
description = "foo" | ||
"#, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: One less indentation?
@bors r+ |
☀️ Test successful - checks-actions |
Update cargo 14 commits in 7ac9416d82cd4fc5e707c9ec3574d22dff6466e5..c91a693e7977e33a1064b63a5daf5fb689f01651 2023-07-24 14:29:38 +0000 to 2023-07-31 00:26:46 +0000 - fix: align `cargo --help` text (rust-lang/cargo#12418) - fix: normalize relative git submodule urls with `ssh://` (rust-lang/cargo#12411) - test: relax help text assertion (rust-lang/cargo#12416) - test: relax assertions of panic handler message format (rust-lang/cargo#12413) - fix(package): Recognize and normalize `cargo.toml` (rust-lang/cargo#12399) - Clarify `lto` setting passing `-Clinker-plugin-lto` (rust-lang/cargo#12407) - doc: add missing reference to `CARGO_PROFILE_<name>_STRIP` in environment variables docs (rust-lang/cargo#12408) - Update curl-sys to pull in curl 8.2.1 (rust-lang/cargo#12406) - docs: raise awareness of resolver used inside workspace (rust-lang/cargo#12388) - chore: update `home` to 0.5.7 (rust-lang/cargo#12401) - Update curl-sys to pull in curl 8.2.0 (rust-lang/cargo#12400) - test(cli): Track --help output (rust-lang/cargo#11912) - refactor(test): Move cargo-config into a dir (rust-lang/cargo#12398) - refactor(tests): Name init ui tests more consistently (rust-lang/cargo#12397) r? `@ghost`
What does this PR try to resolve?
This solution is a blend of conservative and easy
cargo.toml
toCargo.toml
on publishprepare_for_publish
version and includeCargo.toml.orig
Cargo.toml
Cargo.toml
are warningscargo.toml
caseAs a side effect, if a Linux user has
cargo.toml
andCargo.toml
, we'll only put one of them in the.crate
file. We can extend this out to also include a warning for portability for case insensitive filesystems but I left that for after #12235.How should we test and review this PR?
A PR at a time will show how the behavior changed as the source was edited
This does add a direct dependency on
unicase
to help keep case-insensitive comparisons easy / clear and to avoid riskier areas for bugs like writing an appropriateHash
implementation.unicase
is an existing transitive dependency of cargo.Additional information
Fixes #12384
Discussion on Zulip