microsoft / vscode-python

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

Python locator not detecting pixi in latest release & preview #24310

Open ChristianRothQC opened 6 days ago

ChristianRothQC commented 6 days ago

Type: Bug

Behaviour

pixi environment is not properly activated in python Testing tab after updating to latest vscode & python plugins. Both release & preview seem to be affected. Error message:

2024-10-15 11:11:21.462 [info] shell: bash
2024-10-15 11:11:21.477 [info] > conda run -n default --no-capture-output python ~/.vscode/extensions/ms-python.python-2024.17.2024101402-darwin-arm64/python_files/get_output_via_markers.py -m pytest -p vscode_pytest --collect-only tests --no-cov
2024-10-15 11:11:21.477 [info] cwd: .
2024-10-15 11:11:21.610 [error] 
EnvironmentLocationNotFound: Not a conda environment: /Users/christianroth/miniforge3/envs/default

Steps to reproduce:

mkdir -p /tmp/test
cd /tmp/test
pixi init
pixi add python
pixi run ls
code /tmp/test

Navigate to Testing panel.

Diagnostic data

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

``` 2024-10-15 11:07:33.620 [info] Experiment 'pythonRecommendTensorboardExt' is active 2024-10-15 11:07:33.620 [info] Experiment 'pythonSurveyNotification' is active 2024-10-15 11:07:33.620 [info] Experiment 'pythonTerminalEnvVarActivation' is active 2024-10-15 11:07:33.620 [info] Experiment 'pythonTestAdapter' is active 2024-10-15 11:07:33.620 [info] Python interpreter path: ./.pixi/envs/default/bin/python 2024-10-15 11:07:33.620 [info] > conda info --json 2024-10-15 11:07:33.621 [info] > pyenv which python 2024-10-15 11:07:33.621 [info] cwd: . 2024-10-15 11:07:33.640 [info] > pixi --version 2024-10-15 11:07:33.716 [info] > pixi shell-hook --manifest-path ./pixi.toml --shell zsh 2024-10-15 11:07:34.012 [info] > conda config --get auto_activate_base 2024-10-15 11:07:34.012 [info] > . "~/miniforge3/etc/conda/deactivate.d/libxml2_deactivate.sh" && export PATH="./.pixi/envs/default/bin:~/miniforge3/condabin:~/.rd/bin:~/.pixi/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Applications/iTerm.app/Contents/Resources/utilities" && export CONDA_PREFIX="./.pixi/envs/default" && export PIXI_EXE="/opt/homebrew/bin/pixi" && export PIXI_PROJECT_VERSION="0.1.0" && export PIXI_IN_SHELL="1" && export PIXI_PROJECT_MANIFEST="./pixi.toml" && export PIXI_PROJECT_ROOT="." && export PIXI_PROJECT_NAME="test" && export CONDA_DEFAULT_ENV="test" && export PIXI_ENVIRONMENT_NAME="default" && export PIXI_ENVIRONMENT_PLATFORMS="osx-arm64" && export PIXI_PROMPT="(test) " && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2024.17.2024101402-darwin-arm64/python_files/printEnvVariables.py 2024-10-15 11:07:34.012 [info] shell: zsh 2024-10-15 11:07:34.042 [info] > /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2024.17.2024101402-darwin-arm64/python_files/printEnvVariables.py 2024-10-15 11:07:34.042 [info] shell: zsh 2024-10-15 11:07:34.134 [info] Setting environment variable CONDA_DEFAULT_ENV in collection to test {"applyAtShellIntegration":true,"applyAtProcessCreation":true} 2024-10-15 11:07:34.135 [info] Setting environment variable CONDA_PREFIX in collection to /private/tmp/test/.pixi/envs/default {"applyAtShellIntegration":true,"applyAtProcessCreation":true} 2024-10-15 11:07:34.135 [info] Prepending environment variable PATH in collection to /Users/christianroth/.vscode/extensions/ms-python.python-2024.17.2024101402-darwin-arm64/python_files/deactivate/zsh:/private/tmp/test/.pixi/envs/default/bin:/Users/christianroth/miniforge3/condabin:/Users/christianroth/.rd/bin:/Users/christianroth/.pixi/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Applications/iTerm.app/Contents/Resources/utilities: {"applyAtShellIntegration":true,"applyAtProcessCreation":true} 2024-10-15 11:07:34.135 [info] Setting environment variable PIXI_EXE in collection to /opt/homebrew/bin/pixi {"applyAtShellIntegration":true,"applyAtProcessCreation":true} 2024-10-15 11:07:34.135 [info] Setting environment variable PIXI_PROJECT_VERSION in collection to 0.1.0 {"applyAtShellIntegration":true,"applyAtProcessCreation":true} 2024-10-15 11:07:34.135 [info] Setting environment variable PIXI_IN_SHELL in collection to 1 {"applyAtShellIntegration":true,"applyAtProcessCreation":true} 2024-10-15 11:07:34.135 [info] Setting environment variable PIXI_PROJECT_MANIFEST in collection to /private/tmp/test/pixi.toml {"applyAtShellIntegration":true,"applyAtProcessCreation":true} 2024-10-15 11:07:34.135 [info] Setting environment variable PIXI_PROJECT_ROOT in collection to /private/tmp/test {"applyAtShellIntegration":true,"applyAtProcessCreation":true} 2024-10-15 11:07:34.135 [info] Setting environment variable PIXI_PROJECT_NAME in collection to test {"applyAtShellIntegration":true,"applyAtProcessCreation":true} 2024-10-15 11:07:34.135 [info] Setting environment variable PIXI_ENVIRONMENT_NAME in collection to default {"applyAtShellIntegration":true,"applyAtProcessCreation":true} 2024-10-15 11:07:34.135 [info] Setting environment variable PIXI_ENVIRONMENT_PLATFORMS in collection to osx-arm64 {"applyAtShellIntegration":true,"applyAtProcessCreation":true} 2024-10-15 11:07:34.135 [info] Setting environment variable PIXI_PROMPT in collection to (test) {"applyAtShellIntegration":true,"applyAtProcessCreation":true} 2024-10-15 11:07:34.135 [info] Prepending environment variable PS1 in collection with (default) {"applyAtShellIntegration":true,"applyAtProcessCreation":false} 2024-10-15 11:07:34.135 [info] Send text to terminal: /usr/bin/python3 /Users/christianroth/.vscode/extensions/ms-python.python-2024.17.2024101402-darwin-arm64/python_files/printEnvVariablesToFile.py /Users/christianroth/.vscode/extensions/ms-python.python-2024.17.2024101402-darwin-arm64/python_files/deactivate/zsh/envVars.txt 2024-10-15 11:07:44.077 [info] Starting Pylance language server. 2024-10-15 11:11:21.322 [info] Discover tests for workspace name: test - uri: /private/tmp/test 2024-10-15 11:11:21.322 [info] Running discovery for pytest using the new test adapter. 2024-10-15 11:11:21.323 [info] All environment variables set for pytest discovery: **REDACTED** 2024-10-15 11:11:21.325 [info] > pixi shell-hook --manifest-path ./pixi.toml --shell bash 2024-10-15 11:11:21.462 [info] > . "~/miniforge3/etc/conda/deactivate.d/libxml2_deactivate.sh" && export PATH="./.pixi/envs/default/bin:~/miniforge3/condabin:~/.rd/bin:~/.pixi/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Applications/iTerm.app/Contents/Resources/utilities" && export CONDA_PREFIX="./.pixi/envs/default" && export PIXI_PROJECT_ROOT="." && export PIXI_PROJECT_NAME="test" && export PIXI_IN_SHELL="1" && export PIXI_EXE="/opt/homebrew/bin/pixi" && export PIXI_PROJECT_MANIFEST="./pixi.toml" && export PIXI_PROJECT_VERSION="0.1.0" && export CONDA_DEFAULT_ENV="test" && export PIXI_ENVIRONMENT_NAME="default" && export PIXI_ENVIRONMENT_PLATFORMS="osx-arm64" && export PIXI_PROMPT="(test) " && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2024.17.2024101402-darwin-arm64/python_files/printEnvVariables.py 2024-10-15 11:11:21.462 [info] shell: bash 2024-10-15 11:11:21.477 [info] > conda run -n default --no-capture-output python ~/.vscode/extensions/ms-python.python-2024.17.2024101402-darwin-arm64/python_files/get_output_via_markers.py -m pytest -p vscode_pytest --collect-only tests --no-cov 2024-10-15 11:11:21.477 [info] cwd: . 2024-10-15 11:11:21.610 [error] EnvironmentLocationNotFound: Not a conda environment: /Users/christianroth/miniforge3/envs/default 2024-10-15 11:11:21.627 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace /private/tmp/test. 2024-10-15 11:11:21.627 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace /private/tmp/test. Creating and sending error discovery payload 2024-10-15 11:11:21.627 [error] pytest test discovery error for workspace: /private/tmp/test The python test process was terminated before it could exit on its own, the process errored with: Code: 1, Signal: null for workspace /private/tmp/test ```

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

``` 2024-10-15 11:07:33.620 [info] Starting Python Locator /Users/christianroth/.vscode/extensions/ms-python.python-2024.17.2024101402-darwin-arm64/python-env-tools/bin/pet server 2024-10-15 11:07:33.728 [info] Discovered env: /usr/bin/python3 2024-10-15 11:07:33.728 [info] Discovered manager: (Conda) /Users/christianroth/miniforge3/bin/conda 2024-10-15 11:07:33.728 [info] Discovered env: /Users/christianroth/miniforge3/bin/python 2024-10-15 11:07:33.728 [info] Locator Conda took 115.332875ms 2024-10-15 11:07:33.728 [info] Locator Homebrew took 108.604542ms 2024-10-15 11:07:33.728 [info] Locator MacCommandLineTools took 109.581166ms 2024-10-15 11:07:33.728 [info] Locator MacPythonOrg took 9.875µs 2024-10-15 11:07:33.728 [info] Locator MacXCode took 141µs 2024-10-15 11:07:33.728 [info] Locator PipEnv took 37.167µs 2024-10-15 11:07:33.728 [info] Locator Poetry took 108.75475ms 2024-10-15 11:07:33.728 [info] Locator PyEnv took 201.333µs 2024-10-15 11:07:33.728 [info] Locator Venv took 26.875µs 2024-10-15 11:07:33.728 [info] Locator VirtualEnv took 5.25µs 2024-10-15 11:07:33.728 [info] Locator VirtualEnvWrapper took 12.083µs 2024-10-15 11:07:33.728 [info] Locator GlobalVirtualEnvs took 55.584µs 2024-10-15 11:07:33.728 [info] Locator Locators took 115.39375ms 2024-10-15 11:07:33.728 [info] Locator Path took 116.129083ms 2024-10-15 11:07:33.728 [info] Locator Workspaces took 108.740458ms 2024-10-15 11:07:33.728 [info] Refresh completed in 116ms ```

Extension version: 2024.17.2024101402 VS Code version: Code 1.94.0 (d78a74bcdfad14d5d3b1b782f87255d802b57511, 2024-10-02T13:08:12.626Z) OS version: Darwin arm64 23.6.0 Modes:

User Settings

``` languageServer: "Pylance" testing • pytestArgs: "" • pytestEnabled: true ```

Installed Extensions |Extension Name|Extension Id|Version| |---|---|---| |Azure Account|ms-vscode.azure-account|0.12.0| |Azure Pipelines|ms-azure-devops.azure-pipelines|1.237.0| |Azure Resources|ms-azuretools.vscode-azureresourcegroups|0.9.7| |Even Better TOML|tamasfe.even-better-toml|0.19.2| |GitHub Copilot|GitHub.copilot|1.238.0| |GitHub Copilot Chat|GitHub.copilot-chat|0.21.2| |JavaScript Debugger|ms-vscode.js-debug|1.94.0| |JavaScript Debugger Companion Extension|ms-vscode.js-debug-companion|1.1.3| |Jupyter|ms-toolsai.jupyter|2024.9.1| |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.19| |Jupyter Slide Show|ms-toolsai.vscode-jupyter-slideshow|0.1.6| |Mypy Type Checker|ms-python.mypy-type-checker|2024.0.0| |Pylance|ms-python.vscode-pylance|2024.10.1| |Python|ms-python.python|2024.17.2024101402| |Python Debugger|ms-python.debugpy|2024.13.2024101402| |Ruff|charliermarsh.ruff|2024.50.0| |Table Visualizer for JavaScript Profiles|ms-vscode.vscode-js-profile-table|1.0.10|
System Info |Item|Value| |---|---| |CPUs|Apple M3 Max (16 x 2400)| |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
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off| |Load (avg)|2, 2, 3| |Memory (System)|64.00GB (8.81GB free)| |Process Argv|--crash-reporter-id 42cef842-40f4-4638-b715-416262941203| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805cf:30301675 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:31024239 vscaat:30438848 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 pythonnoceb:30805159 asynctok:30898717 pythonmypyd1:30879173 2e7ec940:31000449 pythontbext0:30879054 accentitlementst:30995554 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 01bff139:31013167 a69g1124:31058053 dvdeprecation:31068756 dwnewjupytercf:31046870 impr_priority:31102340 nativerepl2:31139839 refactort:31108082 pythonrstrctxt:31112756 wkspc-onlycs-t:31132770 wkspc-ranged-t:31151552 cf971741:31144450 defaultse:31146405 iacca2:31156134 notype1cf:31157160 5fd0e150:31155592 iconenabled:31158251 ```
ruben-arts commented 6 days ago

It seems to be broken since 2024.16.0. I can reproduce the issue on my Windows machine.

It seems I can't put my finger on it but it looks like the conda locator is incorrectly being triggered.

Edit: version 2024.16.0 not 2023.x.x

karthiknadig commented 5 days ago

The current pixi handling broke conda (in cases without pixi). I am working on re-writing that part to address it in a way where the pixi bits are only used when pixi is installed.