Skip to content
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

"python.condaPath" not used during pytest discovery #24585

Open
dholth opened this issue Dec 11, 2024 · 2 comments
Open

"python.condaPath" not used during pytest discovery #24585

dholth opened this issue Dec 11, 2024 · 2 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team

Comments

@dholth
Copy link

dholth commented Dec 11, 2024

Type: Bug

Behaviour

vscode-python uses random conda binary for failed pytest discovery.

Steps to reproduce:

  1. Install several miniconda distributions into separate directories in ~/miniconda3, ~/miniconda5, ~/minicondax86
  2. Create a development environment with conda and pytest "conda create -n condarun pytest conda"
  3. Set conda path in settings to `"python.condaPath": "/miniconda3/bin/conda",
  4. Select new environment, note conda search in Output (Python) window
2024-12-11 11:17:15.171 [info] Native locator: Refresh started
2024-12-11 11:17:15.187 [info] Conda environment manager found at: /Users/dholth/miniconda3/bin/conda
2024-12-11 11:17:15.221 [info] Conda environment manager found at: /Users/dholth/miniconda5/bin/conda
2024-12-11 11:17:15.223 [info] Conda environment manager found at: /Users/dholth/minicondax86/bin/conda
2024-12-11 11:17:15.224 [info] Conda environment manager found at: /Users/dholth/miniforge3/bin/conda
2024-12-11 11:17:15.253 [info] Native locator: Refresh finished in 82 ms
  1. Set up, discover pytest. Observe Output (Python) window using random conda binary /Users/dholth/miniforge3/bin/conda instead of "python.condaPath"
2024-12-11 11:18:24.774 [error] getActivatedEnvironmentVariables [Error: Command failed: /Users/dholth/miniforge3/bin/conda run -n pupa --no-capture-output python /Users/dholth/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/get_output_via_markers.py /Users/dholth/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/printEnvVariables.py

Diagnostic data

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

Note that /Users/dholth/minicondax86/bin/conda is used below. I want it to use the configured conda, not a randomly discovered, very outdated one.

2024-12-11 11:31:38.856 [info] Native locator: Refresh started
2024-12-11 11:31:38.872 [info] Conda environment manager found at: /Users/dholth/miniconda3/bin/conda
2024-12-11 11:31:38.935 [info] Conda environment manager found at: /Users/dholth/miniforge3/bin/conda
2024-12-11 11:31:38.936 [info] Conda environment manager found at: /Users/dholth/miniconda5/bin/conda
2024-12-11 11:31:38.939 [info] Conda environment manager found at: /Users/dholth/minicondax86/bin/conda
2024-12-11 11:31:38.973 [info] Native locator: Refresh finished in 116 ms
2024-12-11 11:31:41.979 [info] Discover tests for workspace name: conda-pupa - uri: /Users/dholth/prog/conda-pupa
2024-12-11 11:31:41.979 [info] Running discovery for pytest using the new test adapter.
2024-12-11 11:31:41.980 [info] Python interpreter path: ~/miniconda3/envs/pupa/bin/python
2024-12-11 11:31:41.981 [info] Setting environment variable _CE_M in collection to  {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 11:31:41.982 [info] Setting environment variable XML_CATALOG_FILES in collection to file:///Users/dholth/miniconda3/envs/pupa/etc/xml/catalog file:///etc/xml/catalog file:///Users/dholth/miniconda3/envs/pupa/etc/xml/catalog file:///etc/xml/catalog {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 11:31:41.982 [info] Setting environment variable CONDA_ROOT in collection to /Users/dholth/miniconda3 {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 11:31:41.982 [info] Setting environment variable CONDA_PREFIX in collection to /Users/dholth/miniconda3/envs/pupa {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 11:31:41.982 [info] Setting environment variable CONDA_PROMPT_MODIFIER in collection to (pupa)  {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 11:31:41.982 [info] Setting environment variable CONDA_STACKED_3 in collection to true {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 11:31:41.982 [info] Setting environment variable _CE_CONDA in collection to  {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 11:31:41.982 [info] Setting environment variable CONDA_SHLVL in collection to 3 {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 11:31:41.982 [info] Setting environment variable XPC_SERVICE_NAME in collection to 0 {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 11:31:41.982 [info] Setting environment variable CONDA_DEFAULT_ENV in collection to pupa {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 11:31:41.982 [info] Prepending environment variable PATH in collection with /Users/dholth/miniconda3/envs/pupa/bin: {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 11:31:41.982 [info] Setting environment variable CONDA_PREFIX_2 in collection to /Users/dholth/miniconda3/envs/pupax {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-11 11:31:41.982 [info] Prepending environment variable PS1 in collection with (pupa)  {"applyAtShellIntegration":true,"applyAtProcessCreation":false}
2024-12-11 11:31:41.985 [info] All environment variables set for pytest discovery: 
...
2024-12-11 11:31:41.988 [info] > ~/minicondax86/bin/conda run -n pupa --no-capture-output python ~/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/printEnvVariables.py
2024-12-11 11:31:41.988 [info] shell: bash
2024-12-11 11:31:42.711 [error] getActivatedEnvironmentVariables [Error: Command failed: /Users/dholth/minicondax86/bin/conda run -n pupa --no-capture-output python /Users/dholth/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/get_output_via_markers.py /Users/dholth/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/printEnvVariables.py

EnvironmentLocationNotFound: Not a conda environment: /Users/dholth/minicondax86/envs/pupa


	at genericNodeError (node:internal/errors:984:15)
	at wrappedFn (node:internal/errors:538:14)
	at ChildProcess.exithandler (node:child_process:423:12)
	at ChildProcess.emit (node:events:531:35)
	at maybeClose (node:internal/child_process:1105:16)
	at ChildProcess._handle.onexit (node:internal/child_process:305:5)] {
  code: 1,
  killed: false,
  signal: null,
  cmd: '/Users/dholth/minicondax86/bin/conda run -n pupa --no-capture-output python /Users/dholth/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/get_output_via_markers.py /Users/dholth/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/printEnvVariables.py'
}
2024-12-11 11:31:42.714 [info] > ~/minicondax86/bin/conda run -n pupa --no-capture-output python ~/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/get_output_via_markers.py -m pytest -p vscode_pytest --collect-only .
2024-12-11 11:31:42.714 [info] cwd: .
2024-12-11 11:31:43.049 [error] 
EnvironmentLocationNotFound: Not a conda environment: /Users/dholth/minicondax86/envs/pupa


2024-12-11 11:31:43.083 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace /Users/dholth/prog/conda-pupa.
2024-12-11 11:31:43.083 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace /Users/dholth/prog/conda-pupa. Creating and sending error discovery payload
2024-12-11 11:31:43.083 [error] pytest test discovery error for workspace:  /Users/dholth/prog/conda-pupa 
  
 The python test process was terminated before it could exit on its own, the process errored with: Code: 1, Signal: null for workspace /Users/dholth/prog/conda-pupa

Extension version: 2024.20.0
VS Code version: Code 1.95.3 (Universal) (f1a4fb101478ce6ec82fe9627c43efbf9e98c813, 2024-11-13T14:50:04.152Z)
OS version: Darwin arm64 24.1.0
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.12.5
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda 24.11.0
  • Value of the python.languageServer setting: Default
User Settings


condaPath: "/Users/dholth/miniconda3/bin/conda"

languageServer: "Pylance"

testing
• pytestArgs:     "python.testing.pytestArgs": [
        "--no-cov",
        "--basetemp=/tmp/pytesttmp-conda"
    ],
• pytestEnabled: true

Installed Extensions
Extension Name Extension Id Version
Azure Repos ms-vscode.azure-repos 0.40.0
Black Formatter ms-python.black-formatter 2024.4.0
Even Better TOML tamasfe.even-better-toml 0.19.2
GitHub Repositories GitHub.remotehub 0.64.0
GitLens — Git supercharged eamodio.gitlens 16.0.5
JavaScript Debugger ms-vscode.js-debug 1.95.3
JavaScript Debugger Companion Extension ms-vscode.js-debug-companion 1.1.3
Pylance ms-python.vscode-pylance 2024.12.1
Python ms-python.python 2024.20.0
Python Debugger ms-python.debugpy 2024.12.0
Remote - SSH ms-vscode-remote.remote-ssh 0.115.1
Remote - SSH: Editing Configuration Files ms-vscode-remote.remote-ssh-edit 0.87.0
Remote Explorer ms-vscode.remote-explorer 0.4.3
Remote Repositories ms-vscode.remote-repositories 0.42.0
Rewrap stkb.rewrap 1.16.3
Ruff charliermarsh.ruff 2024.56.0
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.10
Todo Tree Gruntfuggly.todo-tree 0.0.226
YAML redhat.vscode-yaml 1.15.0
System Info
Item Value
CPUs Apple M1 Pro (10 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) 1, 2, 3
Memory (System) 16.00GB (0.07GB free)
Process Argv . --crash-reporter-id e18e76d9-d573-4f56-8c99-77786b05ef14
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
2i9eh265:30646982
962ge761:30959799
pythonnoceb:30805159
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
dvdeprecation:31068756
dwnewjupytercf:31046870
nativerepl2:31139839
pythonrstrctxt:31112756
nativeloc1:31192215
cf971741:31144450
iacca1:31171482
notype1:31157159
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530

@eleanorjboyd
Copy link
Member

@anthonykim1 thoughts here?

@eleanorjboyd eleanorjboyd self-assigned this Dec 11, 2024
@github-actions github-actions bot added the info-needed Issue requires more information from poster label Dec 11, 2024
@gandhis1
Copy link

@karthiknadig I'm seeing a similar thing in #24627 to here, in that it uses a seemingly random conda binary. On older versions of the extension, it would use the global conda, and then now it uses some one located in another repo. That said, I don't think that is the proximate cause of my issue, rather that it's referencing the environment by name (-n) instead of path (-p).

@karthiknadig karthiknadig added the bug Issue identified by VS Code Team member as probable bug label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

4 participants