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 py spurious stderr failure #1885

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

jnnnnn
Copy link
Contributor

@jnnnnn jnnnnn commented Feb 22, 2024

Summary

On Windows 10.0.19045 the py command prints to stderr even when working correctly. This means that uv should not treat this as a failure.

Fixes #1904

Test Plan

I ran the modified code and it worked. I expect the pull request to run automated tests.

Copy link
Member

@zanieb zanieb left a comment

Choose a reason for hiding this comment

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

Sounds good to me!

@zanieb zanieb added the bug Something isn't working label Feb 22, 2024
@charliermarsh
Copy link
Member

(Would be good to get eyes on this from whoever wrote it, to know why it was here in the first place.)

@charliermarsh charliermarsh added the windows Specific to the Windows platform label Feb 22, 2024
@zanieb
Copy link
Member

zanieb commented Feb 23, 2024

We had similar logic like this in the LSP? I feel like it's bad form to use content in stderr as a bad exit. I agree it'd be nice to get another review.

@charliermarsh
Copy link
Member

Agree.

@@ -344,8 +344,8 @@ mod windows {
.in_scope(|| Command::new("py").arg("--list-paths").output())
.map_err(Error::PyList)?;

// There shouldn't be any output on stderr.
if !output.status.success() || !output.stderr.is_empty() {
// `py` sometimes prints "Installed Pythons found by py Launcher for Windows" to stderr which we ignore.
Copy link
Member

Choose a reason for hiding this comment

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

That's funny that it only does this sometimes. I tried to reproduce this on my machine with the official py launcher and never managed to get it write to stderr.

I don't mind the change but we may want to log the stderr output with tracing::debug!() if it's non empty. It might be helpful when debugging issues related to py.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

It's consistent on my machine; I meant "sometimes" as in depending on which windows box you're on.

My py does this in a command window as well as bash (mingw).

@konstin
Copy link
Member

konstin commented Feb 23, 2024

(Would be good to get eyes on this from whoever wrote it, to know why it was here in the first place.)

This was just defensive programming

@zanieb zanieb merged commit bd59076 into astral-sh:main Feb 23, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working windows Specific to the Windows platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Running py --list-paths failed with status exit code: 0
5 participants