microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.3k stars 1.18k forks source link

Python extension can't show the list of poetry venv in a special situation #23216

Open dangjinghao opened 5 months ago

dangjinghao commented 5 months ago

Type: Bug

Behaviour

Python extension can't show the list of poetry venv in a special situation

Steps to reproduce:

  1. Create a new python venv and install dependencies with poetry

  2. Add source mirror infomation to pyproject.toml like that

    [[tool.poetry.source]]
    name = "example"
    url = "https://mirrors.example.com/web/simple"
  3. Open this project with vscode

  4. Select interpreter

  5. The poetry venv of current project exists, but python extension doesn't list it

  6. Resolve it by adding priority = "explicit" (Ensure that no output is sent to stderr)

  7. Perhaps, due to the warning messsages poetry outputs to stderr, python extension raises an error. But poetry still prints environment path as usual,why does python extension raise an error for the stderr which contains not useful data?

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

``` 2024-04-10 17:48:23.216 [info] > poetry env list --full-path 2024-04-10 17:48:23.216 [info] cwd: . 2024-04-10 17:48:23.231 [info] Found: /bin/python --> /bin/python3.12 2024-04-10 17:48:23.232 [info] Found: /bin/python3 --> /bin/python3.12 2024-04-10 17:48:23.232 [info] Found: /bin/python3.12 --> /bin/python3.12 2024-04-10 17:48:23.260 [info] Found: /usr/bin/python --> /usr/bin/python3.12 2024-04-10 17:48:23.261 [info] Found: /usr/bin/python3 --> /usr/bin/python3.12 2024-04-10 17:48:23.261 [info] Found: /usr/bin/python3.12 --> /usr/bin/python3.12 2024-04-10 17:48:24.064 [error] [Error: Warning: In a future version of Poetry, PyPI will be disabled automatically if at least one custom source is configured with another priority than 'explicit'. In order to avoid a breaking change and make your pyproject.toml forward compatible, add PyPI explicitly via 'poetry source add pypi'. By the way, this has the advantage that you can set the priority of PyPI as with any other source. at /home/theresa/.vscode/extensions/ms-python.python-2024.4.0/out/client/extension.js:2:219366 at ChildProcess.exithandler (node:child_process:415:7) at ChildProcess.emit (node:events:529:35) at maybeClose (node:internal/child_process:1098:16) at ChildProcess._handle.onexit (node:internal/child_process:303:5)] ```

Extension version: 2024.4.0 VS Code version: Code 1.88.0 (5c3e652f63e798a5ac2f31ffd0d863669328dc4c, 2024-04-03T13:25:57.039Z) OS version: Linux x64 6.8.4-200.fc39.x86_64 Modes:

User Settings

``` languageServer: "Pylance" ```

Installed Extensions |Extension Name|Extension Id|Version| |---|---|---| |autoDocstring - Python Docstring Generator|njpwerner.autodocstring|0.6.1| |autopep8|ms-python.autopep8|2024.0.0| |C/C++|ms-vscode.cpptools|1.19.9| |C/C++ Extension Pack|ms-vscode.cpptools-extension-pack|1.3.0| |C/C++ Themes|ms-vscode.cpptools-themes|2.0.0| |CMake|twxs.cmake|0.0.17| |CMake Tools|ms-vscode.cmake-tools|1.17.17| |Dev Containers|ms-vscode-remote.remote-containers|0.354.0| |Doxygen Documentation Generator|cschlosser.doxdocgen|1.4.0| |Even Better TOML|tamasfe.even-better-toml|0.19.2| |Go|golang.go|0.41.2| |Hex Editor|ms-vscode.hexeditor|1.9.14| |IntelliCode|VisualStudioExptTeam.vscodeintellicode|1.3.1| |IntelliCode API Usage Examples|VisualStudioExptTeam.intellicode-api-usage-examples|0.2.8| |isort|ms-python.isort|2023.10.1| |JavaScript Debugger|ms-vscode.js-debug|1.88.0| |JavaScript Debugger Companion Extension|ms-vscode.js-debug-companion|1.1.2| |Jupyter|ms-toolsai.jupyter|2024.3.0| |Jupyter Cell Tags|ms-toolsai.vscode-jupyter-cell-tags|0.1.9| |Jupyter Keymap|ms-toolsai.jupyter-keymap|1.1.2| |Jupyter Notebook Renderers|ms-toolsai.jupyter-renderers|1.0.17| |Jupyter Slide Show|ms-toolsai.vscode-jupyter-slideshow|0.1.6| |Live Server|ritwickdey.LiveServer|5.7.9| |Makefile Tools|ms-vscode.makefile-tools|0.9.10| |Markdown Checkboxes|bierner.markdown-checkbox|0.4.0| |One Dark Pro|zhuangtongfa.material-theme|3.17.0| |Pylance|ms-python.vscode-pylance|2024.4.1| |Python|ms-python.python|2024.4.0| |Python Debugger|ms-python.debugpy|2024.4.0| |Remote - SSH|ms-vscode-remote.remote-ssh|0.110.1| |Remote - SSH: Editing Configuration Files|ms-vscode-remote.remote-ssh-edit|0.86.0| |Remote - Tunnels|ms-vscode.remote-server|1.5.1| |Remote Explorer|ms-vscode.remote-explorer|0.4.3| |Table Visualizer for JavaScript Profiles|ms-vscode.vscode-js-profile-table|1.0.8| |TODO Highlight|wayou.vscode-todo-highlight|1.0.5|
System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz (8 x 2500)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|3, 2, 2| |Memory (System)|23.22GB (16.10GB free)| |Process Argv|. --crash-reporter-id 59b0364c-98e6-458c-a166-5140ecd75b2d| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|plasma| |XDG_CURRENT_DESKTOP|KDE| |XDG_SESSION_DESKTOP|KDE| |XDG_SESSION_TYPE|wayland|
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:30899288 c4g48928:30535728 azure-dev_surveyone:30548225 a9j8j154:30646983 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 h48ei257:31000450 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 d34g3935:30971562 fegfb526:30981948 bg6jg535:30979843 ccp2r3:30993541 dsvsc020:30976470 pythonait:31006305 gee8j676:31009558 dsvsc021:30996838 g1icg217:30999571 0ee40948:31013168 ```
karthiknadig commented 5 months ago

The current detection code assumes that if something is written to stderr that there is an issue. We need to switch this to rely on the error code, and only use stderr to log.