The Wayback Machine - https://web.archive.org/web/20220422000327/https://github.com/rust-lang/rust/pull/87863
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

Fix Windows Command::env("PATH") #87863

Merged
merged 1 commit into from Aug 12, 2021
Merged

Conversation

Copy link
Contributor

@ChrisDenton ChrisDenton commented Aug 8, 2021

Fixes #87859

@rust-highfive
Copy link
Collaborator

@rust-highfive rust-highfive commented Aug 8, 2021

r? @dtolnay

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review label Aug 8, 2021
@Urgau
Copy link
Contributor

@Urgau Urgau commented Aug 8, 2021

I think this need's to be beta nominated because the PR who introduce the bug is the the current beta.

Copy link
Member

@dtolnay dtolnay left a comment

The impl Borrow<OsStr> for EnvKey lower in this file needs to be removed. That impl was the root cause. The impl is wrong because the Ord and Eq impls have different behavior between OsStr and EnvKey, which violates:

In particular Eq, Ord and Hash must be equivalent for borrowed and owned values: x.borrow() == y.borrow() should give the same result as x == y.

@dtolnay dtolnay added beta-nominated T-libs labels Aug 8, 2021
@ChrisDenton
Copy link
Contributor Author

@ChrisDenton ChrisDenton commented Aug 8, 2021

Ok I've removed the borrow and changed sys_common::process::CommandEnv to work with EnvKey instead of OsStr/OsString. I wonder if it might ultimately be worth Windows using its own implementation of CommandEnv.

@dtolnay
Copy link
Member

@dtolnay dtolnay commented Aug 8, 2021

@bors r+

@bors
Copy link
Contributor

@bors bors commented Aug 8, 2021

📌 Commit 419902e has been approved by dtolnay

@bors bors added S-waiting-on-bors and removed S-waiting-on-review labels Aug 8, 2021
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 9, 2021
@bors
Copy link
Contributor

@bors bors commented Aug 9, 2021

Testing commit 419902e with merge 03e3dd0...

@bors
Copy link
Contributor

@bors bors commented Aug 9, 2021

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review and removed S-waiting-on-bors labels Aug 9, 2021
@rust-log-analyzer
Copy link
Collaborator

@rust-log-analyzer rust-log-analyzer commented Aug 9, 2021

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@ChrisDenton
Copy link
Contributor Author

@ChrisDenton ChrisDenton commented Aug 9, 2021

The failure looks like a spurious timeout or something?

@dtolnay
Copy link
Member

@dtolnay dtolnay commented Aug 9, 2021

@bors retry

@bors bors added S-waiting-on-bors and removed S-waiting-on-review labels Aug 9, 2021
@bors
Copy link
Contributor

@bors bors commented Aug 9, 2021

Testing commit 419902e with merge 32994af...

bors added a commit to rust-lang-ci/rust that referenced this issue Aug 9, 2021
@bors
Copy link
Contributor

@bors bors commented Aug 9, 2021

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review and removed S-waiting-on-bors labels Aug 9, 2021
@rust-log-analyzer
Copy link
Collaborator

@rust-log-analyzer rust-log-analyzer commented Aug 9, 2021

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@ChrisDenton
Copy link
Contributor Author

@ChrisDenton ChrisDenton commented Aug 10, 2021

Hm, this seems to have failed downloading. Third time lucky?

@ehuss
Copy link
Contributor

@ehuss ehuss commented Aug 10, 2021

@bors retry

Failed to download action 'https://api.github.com/repos/actions/checkout/tarball/5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f'. Error: The operation was canceled.

@bors bors added S-waiting-on-bors and removed S-waiting-on-review labels Aug 10, 2021
impl PartialOrd<str> for EnvKey {
fn partial_cmp(&self, other: &str) -> Option<cmp::Ordering> {
Some(self.cmp(&EnvKey::new(other)))
}
}
impl PartialEq<str> for EnvKey {
fn eq(&self, other: &str) -> bool {
if self.os_string.len() != other.len() {
false
} else {
self.cmp(&EnvKey::new(other)) == cmp::Ordering::Equal
}
}
}
Copy link
Member

@m-ou-se m-ou-se Aug 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need these implementations? Silently allocating on every comparison seems like a bad idea.

The PartialEq implementation seems to be used only for == "PATH" and nothing else, so it's not that bad, but it might be good to improve that at some point. The result of that comparison also seems to only affect sys/unix and to be entirely unused on Windows.

The PartialOrd implementation, however, seems unnecessary. It all still compiles when removing it.

Copy link
Contributor Author

@ChrisDenton ChrisDenton Aug 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points. I could remove those implementations and maybe I should add a #[cfg(not(windows))] to have_changed_path? So as to guard against the possibility of it accidentally being used in the future, or at least until a longer term fix is made.

@m-ou-se
Copy link
Member

@m-ou-se m-ou-se commented Aug 11, 2021

For the backport: Would backporting just 593b0eb be enough? It looks to me like the remove() function also had a bug that was discovered by removing the Borrow implementation, so no, correct?

@ChrisDenton
Copy link
Contributor Author

@ChrisDenton ChrisDenton commented Aug 11, 2021

Yeah, remove needs either an EnvKey or else a Borrow that has the same ordering as EnvKey. I could limit the allocation to right before self.vars.remove? That would fix the immediate problem and shouldn't have too much impact.

@m-ou-se
Copy link
Member

@m-ou-se m-ou-se commented Aug 11, 2021

In that case we should probably just backport the PR as is.

I wonder if it might ultimately be worth Windows using its own implementation of CommandEnv.

That's probably a good idea, yes.

bors added a commit to rust-lang-ci/rust that referenced this issue Aug 12, 2021
…laumeGomez

Rollup of 4 pull requests

Successful merges:

 - rust-lang#87819 (Use a more accurate span on assoc types WF checks)
 - rust-lang#87863 (Fix Windows Command::env("PATH"))
 - rust-lang#87885 (Link to edition guide instead of issues for 2021 lints.)
 - rust-lang#87941 (Fix/improve rustdoc-js tool)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit cc54fda into rust-lang:master Aug 12, 2021
10 of 11 checks passed
@rustbot rustbot added this to the 1.56.0 milestone Aug 12, 2021
@m-ou-se m-ou-se added the beta-accepted label Aug 18, 2021
@Mark-Simulacrum Mark-Simulacrum removed the beta-nominated label Aug 27, 2021
@Mark-Simulacrum Mark-Simulacrum removed this from the 1.56.0 milestone Aug 27, 2021
@Mark-Simulacrum Mark-Simulacrum added this to the 1.55.0 milestone Aug 27, 2021
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 28, 2021
…ulacrum

[beta] backports

This PR rolls up a number of beta backports:

* Split critical edge targeting the start block rust-lang#88124
* Make BuildHasher object safe rust-lang#88031
* Fix Windows Command::env("PATH") rust-lang#87863
* Do not ICE on HIR based WF check when involving lifetimes rust-lang#87811
* Update compiler_builtins to fix i128 shift/mul on thumbv6m rust-lang#87633
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted S-waiting-on-bors T-libs
10 participants