microsoft / vscode-python

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

"Invalid Python selected" prompt is shown when create environment command is used in a multi-root workspace #22649

Open luabud opened 10 months ago

luabud commented 10 months ago

Type: Bug

Behaviour

Expected vs. Actual

When using the create environment command in a multi-root workspace, I'm seeing the "Invalid Python selected" notification even though the new venv is correctly selected:

image

Steps to reproduce:

  1. Create a multi-root workspace, ensuring the root-folder is open as its own separate workspace, as well as at least one of its subfolders (i.e. follow the scenario outlined here: https://github.com/microsoft/vscode-python/wiki/Mono-Repo-Set%E2%80%90up-Guide#scenario-2-separate-virtual-environments)
  2. Add a file.exclude setting to exclude the subfolder that you opened as its own workspace from the top-level folder (to avoid "repeated" entries in the file explorer)
  3. Run the create environment command and select the "subfolder workspace ".
  4. The command runs succesfully and the interpreter is correctly picked up, but the "invalid Python selected" prompt shows up.

I reproduced it by cloning https://github.com/microsoft/responsible-ai-toolbox/ and creating the following .code-workspace file under responsible-ai-toolbox/.vscode

{
    "folders": [
        {
            "path": ".."
        },
        {
            "path": "../erroranalysis"
        },
        {
            "path": "../nlp_feature_extractors"
        },
        {
            "path": "../rai_core_flask"
        },
        {
            "path": "../raiutils"
        },
        {
            "path": "../responsibleai"
        },
        {
            "path": "../raiwidgets"
        }
    ],
    "settings": {
        "files.exclude": {
            "erroranalysis/**": true,
            "nlp_feature_extractors/**": true,
            "rai_core_flask/**": true,
            "raiutils/**": true,
            "responsibleai/**": true,
            "raiwidgets/**": true   
        }
    }
}

Diagnostic data

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

``` XXX ```

User Settings

``` Multiroot scenario, following user settings may not apply: languageServer: "Pylance" testing • pytestEnabled: true experiments • optInto: ["pythonTestAdapter","regionCommentDiagnostics"] ```

Extension version: 2023.23.13471011 VS Code version: Code - Insiders 1.86.0-insider (f87fb292c3af22e51a7f5c628496cd8d6fd9ecd5, 2023-12-13T08:07:18.340Z) OS version: Windows_NT x64 10.0.22621 Modes:

System Info |Item|Value| |---|---| |CPUs|11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz (8 x 2995)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
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: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|31.71GB (6.85GB free)| |Process Argv|--log trace --log ms-python.autopep8=debug --crash-reporter-id 11494669-52ca-4f2c-aa0e-29172189cc8e| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv695:30137379 vsins829:30139715 vsliv368cf:30146710 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 pythontb:30258533 vsc_aa:30263845 pythonptprofiler:30281269 vshan820:30294714 vscod805:30301674 bridge0708:30335490 bridge0723:30353136 vsaa593:30376534 pythonvs932:30404738 py29gd2263:30784851 vsclangdf:30492506 c4g48928:30535728 dsvsc012cf:30540253 2i9eh265:30646982 showlangstatbar:30737417 fixshowwlkth:30771523 showindicator:30805243 pythongtdpath:30726887 i26e3531:30792625 welcomedialog:30812478 pythonnosmt12:30779711 pythonidxpt:30768918 pythonnoceb:30776497 asynctok:30898717 dsvsc013:30777762 dsvsc014:30777825 pythonmhint1:30901775 dsvsc015:30821418 pythontestfixt:30866404 pythonregdiag2:30902439 pyreplss1:30879911 pythonmypyd1:30859725 pythoncet0:30859736 pythontbext0:30879054 accentitlementst:30870582 dsvsc016:30879898 dsvsc017:30880771 dsvsc018:30880772 aa_t_chat:30882232 ```
karthiknadig commented 10 months ago

@karrtikr This is the same problem I had seen a few months ago with the same repo. Basically, after the environment is created for one of the workspace folder, we call the update interpreter API with workspace folder URI and executable to the new environment. For some reason it triggers validation of python for other folders.

karrtikr commented 9 months ago

I tried to reproduce it again but I'm not able to. Marking it as "needs spike" to investigate further.