Repository navigation
Test discovery tries to activate conda on a non-conda directory #22581
Copy link
Copy link
Closed as not planned
Labels
area-testingtriage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team
Description
Type: Bug
Behaviour
Expected vs. Actual
Expected that the testing sidebar shows all python tests that are available.
The directory used here is using pixi as package manager, and not conda. Somehow this folder is identified as a conda folder and the ms-python plugin tries to call conda, which is indeed installed on my computer and in my PATH. ms-python should not try to call conda run. I have set up my environment myself my opening visual studio code in a pixi shell.
Actual, I receive an error DirectoryNotACondaEnvironmentError
Steps to reproduce:
- I call
pixi run code .to open my VS code project - I go to the Testing tab to check for pytest tests
Diagnostic data
- Python version (& distribution if applicable, e.g. Anaconda): 3.11.6
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda (actually pixi, but conda seems to be found and used)
- Value of the
python.languageServersetting: Default - I have
"python.terminal.activateEnvironment": false,in my personal settings. - I have tried the pre-release and the stable version
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
2023-12-01 15:51:35.304 [info] ResultResolver EOT received for discovery.
2023-12-01 15:51:35.304 [info] Disposing data receiver for c:\Users\X\Source\Repos\PROJECT and deleting UUID; pytest discovery.
2023-12-01 15:54:07.346 [info] Discover tests for workspace name: PROJECT - uri: c:\Users\X\Source\Repos\PROJECT\.vscode\settings.json
2023-12-01 15:54:07.346 [info] Running discovery for pytest using the new test adapter.
2023-12-01 15:54:07.346 [info] All environment variables set for pytest discovery for workspace [LEFT OUT BY POSTER]
2023-12-01 15:54:07.353 [info] > conda run -p .\.pixi\env --no-capture-output python ~\.vscode\extensions\ms-python.python-2023.21.13351006\pythonFiles\get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.21.13351006/pythonFiles/printEnvVariables.py
2023-12-01 15:54:07.353 [info] shell: commandPrompt
2023-12-01 15:54:08.392 [error] getActivatedEnvironmentVariables Error: Command failed: conda run -p C:\Users\X\Source\Repos\PROJECT\.pixi\env --no-capture-output python c:\Users\X\.vscode\extensions\ms-python.python-2023.21.13351006\pythonFiles\get_output_via_markers.py c:/Users/X/.vscode/extensions/ms-python.python-2023.21.13351006/pythonFiles/printEnvVariables.py
DirectoryNotACondaEnvironmentError: The target directory exists, but it is not a conda environment.
Use 'conda create' to convert the directory to a conda environment.
target directory: C:\Users\X\Source\Repos\PROJECT\.pixi\env
at ChildProcess.exithandler (node:child_process:431:12)
at ChildProcess.emit (node:events:525:35)
at maybeClose (node:internal/child_process:1091:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5) {
code: 1,
killed: false,
signal: null,
cmd: 'conda run -p C:\\Users\\X\\Source\\Repos\\PROJECT\\.pixi\\env --no-capture-output python c:\\Users\\X\\.vscode\\extensions\\ms-python.python-2023.21.13351006\\pythonFiles\\get_output_via_markers.py c:/Users/X/.vscode/extensions/ms-python.python-2023.21.13351006/pythonFiles/printEnvVariables.py'
}
User Settings
languageServer: "Pylance"
testing
• pytestEnabled: true
terminal
• activateEnvironment: false
Extension version: 2023.21.13351006
VS Code version: Code 1.84.2 (1a5daa3a0231a0fbba4f14db7ec463cf99d7768e, 2023-11-09T10:51:52.184Z)
OS version: Windows_NT x64 10.0.19045
Modes:
System Info
| Item | Value |
|---|---|
| CPUs | 12th Gen Intel(R) Core(TM) i5-1235U (12 x 2496) |
| 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 video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled |
| Load (avg) | undefined |
| Memory (System) | 15.64GB (4.32GB free) |
| Process Argv | . --crash-reporter-id 896f8136-38e6-4d41-88b0-79e91aef99a1 |
| Screen Reader | no |
| VM | 0% |
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
py29gd2263:30899288
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
azure-dev_surveyone:30548225
3biah626:30602489
f6dab269:30613381
2i9eh265:30646982
showlangstatbar:30737416
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
welcomedialog:30910333
pythonnosmt12:30797651
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
dsvsc013:30795093
dsvsc014:30804076
dsvsc015:30845448
pythontestfixt:30902429
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
pythontbext0:30879054
accentitlementsc:30887149
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
aa_t_chat:30882232
Reactions are currently unavailable
Metadata
Metadata
Labels
area-testingtriage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team
Activity
eleanorjboyd commentedon Dec 13, 2023
Are you on the new testing rewrite? You can check for it by looking at
Experiment 'pythonTestAdapter'is active in your python logs. If not can you please turn it on and let me know if the behavior changes? You can do so adding this setting to your userssettings.json"python.experiments.optInto": ["pythonTestAdapter"]. If you are unable to see the log for the experiment chance your log level to info or trace and it should show up. Thanks!deltamarnix commentedon Dec 13, 2023
Correct, the pythonTestAdapter is already enabled:
eleanorjboyd commentedon Dec 13, 2023
hm this is especially interesting because this seems right from your logs
2023-12-13 12:22:39.139 [info] Send text to terminal: echo C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe.Kartik Raj (@karrtikr) thoughts?
karrtikr commentedon Dec 13, 2023
This log is expected as we use this information to decide the activation mechanism, doesn't seem related.
eleanorjboyd commentedon Dec 13, 2023
Oops I copied the wrong line. I was looking at this one
python interpreter path: .\.pixi\env\python.exeand not sure why the path is referencing the pixi env as desired in the logs but referencing the conda env when run. What other logs should I be looking for Kartik Raj (@karrtikr)?karrtikr commentedon Dec 13, 2023
It doesn't seem to recognize the type of the active interpreter:
Active interpreter type is detected as Unknown, and for some reason assumes the type to be conda. Seems that pixi as package manager is not supported, I can take this one over.Marnix (@deltamarnix) Can you please provide the debug logs? Also please provide some steps to use that package manager to create such environment, as it would help us in reproducing this issue on our end.
Developer: Set log levelcommandTraceDeveloper: Reload WindowcommandOutput for
Pythonin theOutputpanel (View→Output, change the drop-down the upper-right of theOutputpanel toPython)deltamarnix commentedon Dec 14, 2023
I have created two logs for you. The first one is without anaconda in the path, the second one with anaconda in the path.
After I reload the window, I go to the Testing tab.
The package manager that I'm using is called pixi.
pixi init .to create the pixi installation.pixi add pythonI hope I am complete enough with this information.
My settings.json:
{ "[julia]": { "editor.formatOnSave": true }, "notebook.formatOnSave.enabled": true, "notebook.codeActionsOnSave": { "source.fixAll.ruff": true, "source.organizeImports.ruff": true }, "[python]": { "editor.defaultFormatter": "charliermarsh.ruff", "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.fixAll": "explicit" } }, "python.analysis.extraPaths": [ ".pixi/env/Library/python" ], "mypy-type-checker.importStrategy": "fromEnvironment", "python.testing.pytestArgs": [ "." ], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, "files.exclude": { "**/.git": true, "**/.svn": true, "**/.hg": true, "**/CVS": true, "**/.DS_Store": true, "**/Thumbs.db": true, ".pixi": true, ".mypy_cache": true, ".pytest_cache": true, ".ruff_cache": true, "juliaup": true } }Without anaconda in PATH
With anaconda in PATH
croth1 commentedon Mar 10, 2024
Hey, tripped over exactly the same issue with Version: 1.87.1, Commit: 1e790d77f81672c49be070e04474901747115651, osx-arm64 and pixi as environment manager.
Everything but pytest seems to work just as expected. When discovering the tests, vscode seems convinced it's actually running an interpreter inside a conda environment and fails just like in the original bug report.
Is there any setting that can manually override this behavior? Anything I can do to help troubleshoot further?
Python output
vscode does seem to think already in the interpreter discovery stage that .pixi's interpreter is running from inside a conda environment:

Could this have anything to do with pixi being quite close to the conda ecosystem? Super wild guess, but does the discovery logic maybe get confused by some shared features between pixi and conda environments? The pixi environment in
/Users/christian/repo/xxx/.pixi/envs/defaulte.g. also contains a conda-meta folder.baszalmstra commentedon Mar 11, 2024
I started on better pixi integration in this plugin. The first PR is to detect the proper python interpreter: #22968
After that, I would like to try and tackle some of the issues mentioned here.
eleanorjboyd commentedon Mar 27, 2024
Kartik Raj (@karrtikr), could you circle back on this if you have time? Thanks
karrtikr commentedon Mar 27, 2024
We can close this in favor of #22978.
Bas Zalmstra (@baszalmstra) As part of test plan item of #22968 (comment), we'd very much appreciate it if you could also mention to verify it fixes this issue, thanks!
baszalmstra commentedon Mar 27, 2024
Kartik Raj (@karrtikr) will do!