-
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
Add warning when PATH env separator is in project path #11318
Add warning when PATH env separator is in project path #11318
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @epage (or someone else) soon. Please see the contribution instructions for more information. |
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.
Thanks for the contribution!
tests/testsuite/init/path_contains_separator/in/test:ing/mod.rs
Outdated
Show resolved
Hide resolved
How does this work on Windows? The |
Fair question. I don't typically use Windows, let me set up a VM and do some testing and validation. |
Looking at the CI failure, I'd also add that
A normal file or directory with a |
Thank you for pointing it out! It was my bad providing an imprecise demo error message 🙇🏾♂️. We definitely can have IIUC,
To continue, I'd suggest diverging Footnotes
|
When handling |
You're right! If FWIW, the situation has been improved over time, as the original issue is quite old and |
Considering the differences in existing platforms, instead of diverging |
@RyanAD Sounds like a good idea! Just remember to add a comment explaining why does that. |
@weihanglo @ChrisDenton When you get a chance, here is an updated PR. I didn't add any tests for Windows because I couldn't consistently create a paths with invalid characters. I could set an ENV manually but that wasn't really the point of testing The last remaining item is a test for |
Looks good to me. I guess you could add the reverse test for Windows, i.e. that it doesn't spuriously warn about |
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.
Thank you for the update! The rest looks good to me.
r? weihanglo since you've already been reviewing this (thanks!) |
☔ The latest upstream changes (presumably #11321) made this pull request unmergeable. Please resolve the merge conflicts. |
969ea02
to
eb8d3e2
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.
Looks great! Thank @RyanAD for the contributions, and @ChrisDenton for the expert knowledge of Windows platform!
@bors r+ |
☀️ Test successful - checks-actions |
5 commits in a3dfea71ca0c888a88111086898aa833c291d497..16b097879b6f117c8ae698aab054c87f26ff325e 2022-11-11 03:50:47 +0000 to 2022-11-14 23:28:16 +0000 - improve error message for cargo add/remove (rust-lang/cargo#11375) - Bump crate versions of `cargo-util` and `crates-io` (rust-lang/cargo#11369) - doc(changelog): suggestions of cargo fix are nightly only (rust-lang/cargo#11373) - Add warning when PATH env separator is in project path (rust-lang/cargo#11318) - Fix git2 safe-directory disable (rust-lang/cargo#11366)
Update cargo 5 commits in a3dfea71ca0c888a88111086898aa833c291d497..16b097879b6f117c8ae698aab054c87f26ff325e 2022-11-11 03:50:47 +0000 to 2022-11-14 23:28:16 +0000 - improve error message for cargo add/remove (rust-lang/cargo#11375) - Bump crate versions of `cargo-util` and `crates-io` (rust-lang/cargo#11369) - doc(changelog): suggestions of cargo fix are nightly only (rust-lang/cargo#11373) - Add warning when PATH env separator is in project path (rust-lang/cargo#11318) - Fix git2 safe-directory disable (rust-lang/cargo#11366) r? `@ghost`
Closes #3736
Adds a check during
cargo init
andcargo new
to check if the path contains an invalid PATH character (:
,;
, or"
). These characters can break things in various ways (includingcargo test
). These characters are not valid in certain environment variables and cannot be escaped.For more information see:
https://github.com/rust-lang/rust/blob/7feb003882ecf7699e6705b537673e20985accff/library/std/src/sys/unix/os.rs#L233
https://man7.org/linux/man-pages/man8/ld.so.8.html
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html
https://doc.rust-lang.org/std/env/fn.join_paths.html#errors
To test cargo new and cargo init:
cargo new --name testing test:ing
mkdir test:ing2 && cd 'test:ing2' && cargo init --name testing
To test the updated error message when in a directory with invalid characters:
cargo new testing3 && mv testing3 test:ing3 && cd 'test:ing3' && cargo test
cc @weihanglo