-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
JSONDecodeError on Windows when running Python produces warnings #6664
Comments
I feel like the lede might be buried here -- are you attempting to install into a Windows Python from Linux via WSL? Or are you running a Windows Poetry from WSL? Either way, there are definitely dragons here, and these are only likely to be a few of them. However, it is worth noting that the output that cannot be silenced by |
@neersighted I was inside a directory that indeed looked like I suspect similar edge cases can happen outside of WSL. For example, on Linux, I believe libc itself can throw warnings under extreme circumstances, which you would not be able to silence either. The PR likely fixes that. My proposed fix is safe because none of the |
The 'something' there would be I don't believe there are any cases on a Linux system where you should get output on stderr from non-application code and still have the program run as expected (and it wouldn't be from libc, but instead from the dynamic linker). Anyway, my concerns are on the PR. |
Have you resolved the issue. I am also facing similar error where I try to run poetry install or poetry update command and it gives me error |
#6665 resolves the issue but has yet to get a final review |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Symptom
Running any poetry command would produce the following error:
Diagnosis
Under certain circumstances, running Python produces warnings which cannot simply be silenced by
-W ignore
. This confuses parsing methods.By looking with -vvv, I debugged the issue.
In my case, the output looked like this, with the warning included:
In poetry/utils/env.py, this causes
run_python_script()
to include those warnings in the output (the return value). The output ofrun_python_script()
is parsed very strictly bysys_path
,get_version_info
,get_supported_tags
,get_marker_env
, etc.In none of the cases above should the warning be included in the returned output value.
Resolution
run_python_script
callsrun()
, which is a generic way of getting a command and running it using subprocess. However, further down the stack, the stderr gets merged with the stdout.To solve the issue, I added a
stderr
argument to_run()
, defaulting to its old behaviour. Butrun_python_script
now specifies it, setting it tosubprocess.DEVNULL
. This silences other warnings which were not caught by-W ignore
(I suppose a similar issue happened before, with python-specific warnings, causing this to be included).Will include a PR.
The text was updated successfully, but these errors were encountered: