-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Type: Bug
Behaviour
When attempting to debug a pytest test using Debug Test from the VS Code Testing panel in an anaconda environment, I get the following error:
"Failed to spawn launcher: [Errno 13] Permission denied: '/Users/username/anaconda3/envs/my_conda_env'"
The reason I get that error is that Code attempts to launch the debug server using only the environment's root path rather than than the path to the python executable within that environment. I.e., it calls /Users/username/anaconda3/envs/my_conda_env instead of /Users/username/anaconda3/envs/my_conda_env/bin/python to launch the debugger. And because a directory is not executable, I get the permission denied error.
I used to be able to debug tests no problem. I'm not sure if something in my setup changed or if something in plugin changed. I've googled and played with settings and tried different conda environments. I've tried setting a different "python" option in the debug-test launch configuration (I get errors if I set a bad path for that option, but when it's a good path, it seems to be ignored). I've deleted and recreated the conda environment. I've even deleted and reinstalled VS Code.
I can run tests within VS Code or from the command line without debugging and hit no errors. I can also debug a single python file with the very same launch configuration that is meant for debugging tests (even including the "purpose" option set to ["debug-test"]) by launching the debugger directly. The problem only occurs when launching a debug session through the Debug Test option on the Testing panel.
Steps to reproduce:
- create a conda environment and install pytest
- create a new project workspace
- create a python file in the workspace with a simple function calling, e.g.,
print("Hello, word") - select the conda environment created in step 1 as python environment for the project
- create a
testsfolder in the workspace with a single pytest that calls the test function - go to the Testing panel in VS Code and setup pytest testing
- after test discovery completes, click the "debug test" button next to the test nameResult: VS Code pops up an alert reporting the "Permission denied" error
For more detail, you can set up a debug configuration for the tests in the launch.json file using the exact configuration provided in the Python Extension documentation at: [https://code.visualstudio.com/docs/python/testing#_debug-tests], with the "console" option set to "integratedTerminal" -- there, you can see the command Code is using to attempt to start the debug server.
Diagnostic data
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
2025-09-09 12:36:56.122 [info] > ~/anaconda3/bin/conda run -p ~/anaconda3/envs/my_conda_env --no-capture-output python ~/.vscode/extensions/ms-python.python-2025.12.0-darwin-arm64/python_files/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2025.12.0-darwin-arm64/python_files/printEnvVariables.py
2025-09-09 12:36:56.122 [info] shell: bash
2025-09-09 12:36:57.166 [info] arg: --rootdir already exists in args, not adding.
2025-09-09 12:36:57.166 [info] Attempting to use temp directory for test ids file, file name: test-ids-c79eea80e8781efba974.txt
2025-09-09 12:36:57.166 [info] Environment variables set for pytest execution: PYTHONPATH=/Users/username/.vscode/extensions/ms-python.python-2025.12.0-darwin-arm64/python_files, TEST_RUN_PIPE=/var/folders/7b/j6zzgg8j1v3d83xn_msb1xnw0000gn/T/python-test-results-2a0dee1c2989b48f6149, RUN_TEST_IDS_PIPE=/var/folders/7b/j6zzgg8j1v3d83xn_msb1xnw0000gn/T/test-ids-c79eea80e8781efba974.txt
2025-09-09 12:36:57.166 [info] Running DEBUG pytest with arguments: --rootdir=/Users/username/Source/test_project,--capture=no for workspace /Users/username/Source/test_project
2025-09-09 12:36:57.167 [info] Using configuration in launch.json
Output for integrated terminal panel
(my_conda_env) username@host project_folder % cd /Users/username/Source/project_folder ; /usr/bin/en
v /Users/username/anaconda3/envs/my_conda_env /Users/username/.vscode/extensions/ms-python.debugpy-2025.10.0-d
arwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/launcher 50578 -- /Users/username/.vscode/extensions
/ms-python.python-2025.12.0-darwin-arm64/python_files/vscode_pytest/run_pytest_script.py --rootdir=/Users
/username/Source/project_folder --capture=no
env: /Users/username/anaconda3/envs/my_conda_env: Permission denied
Extension version: 2025.12.0
VS Code version: Code 1.103.2 (6f17636121051a53c88d3e605c491d22af2ba755, 2025-08-20T16:45:34.255Z)
OS version: Darwin arm64 24.6.0
Modes:
- Python version (& distribution if applicable, e.g. Anaconda): 3.12.11
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
- Value of the
python.languageServersetting: Default
User Settings
condaPath: "~/anaconda3/bin/conda"
languageServer: "Pylance"
testing
• pytestArgs: "--no-cov"
• pytestEnabled: true
Installed Extensions
| Extension Name | Extension Id | Version |
|---|---|---|
| cmake-tools | ms- | 1.21.36 |
| copilot | Git | 1.364.0 |
| copilot-chat | Git | 0.30.3 |
| cpptools | ms- | 1.26.3 |
| cpptools-extension-pack | ms- | 1.3.1 |
| cpptools-themes | ms- | 2.0.0 |
| datawrangler | ms- | 1.22.0 |
| debugpy | ms- | 2025.10.0 |
| hexeditor | ms- | 1.11.1 |
| intellicode-api-usage-examples | Vis | 0.2.9 |
| js-debug | ms- | 1.102.0 |
| js-debug-companion | ms- | 1.1.3 |
| jupyter | ms- | 2025.7.0 |
| jupyter-keymap | ms- | 1.1.2 |
| jupyter-renderers | ms- | 1.3.0 |
| makefile-tools | ms- | 0.12.17 |
| python | ms- | 2025.12.0 |
| ruff | cha | 2025.24.0 |
| vscode-js-profile-table | ms- | 1.0.10 |
| vscode-jupyter-cell-tags | ms- | 0.1.9 |
| vscode-jupyter-slideshow | ms- | 0.1.6 |
| vscode-pylance | ms- | 2025.7.1 |
| vscode-python-envs | ms- | 1.2.0 |
| vscodeintellicode | Vis | 1.3.2 |
System Info
| Item | Value |
|---|---|
| CPUs | Apple M1 Max (10 x 2400) |
| GPU Status | 2d_canvas: enabled 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: enabled_on trees_in_viz: disabled_off video_decode: enabled video_encode: enabled webgl: enabled webgl2: enabled webgpu: enabled webnn: disabled_off |
| Load (avg) | 6, 15, 15 |
| Memory (System) | 64.00GB (6.59GB free) |
| Process Argv | --crash-reporter-id 7daef490-db9b-4617-abaa-559a02220920 |
| Screen Reader | no |
| VM | 0% |
A/B Experiments
vsliv368:30146709
pythonvspyt551:31249599
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
996jf627:31283433
pythonrdcb7:31342333
usemplatestapi:31297334
6518g693:31334701
aj953862:31281341
nesew2to5:31336538
agentclaude:31374413
4f60g487:31327383
nes-set-on:31340697
6abeh943:31336334
envsactivate1:31353494
0927b901:31350571
45650338:31358607
0cj2b977:31352657
gaj49834:31362110
pylancealldocsf:31379511
gemagent1:31368469
cloudbuttont:31379625
retryenabled:31370050
3efgi100_wstrepl:31382709
trigger-command-fix:31379601