No support for per-subpackage launch.json + in monorepo: debugger breaks imports that terminal run resolves
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start by reproducing the supplied monorepo layout and launch.json, then compare the terminal and F5 subprocess environments, including cwd and PYTHONPATH. Trace debugpy's launch-time environment and path handling; done means user paths are preserved or the overwritten variables are documented precisely, with the provided module launch no longer failing.
Written by the indexing model from the issue text.
Description
Environment
- OS: Windows 11 Enterprise
- VS Code: 1.104.x
- debugpy: latest (1.8.x)
- Python: 3.11
- Repo layout: monorepo with
src/layout; each sub-package atpackages/<name>/src/<name>/ - Shell: PowerShell
Problem
In a monorepo with a src/ layout, running python -m packages.api.main from the workspace root works in a terminal (with PYTHONPATH=packages/api/src). But when launching the same target via VS Code's debugger ("module": "packages.api.main" in launch.json), debugpy prepends its own path manipulation that:
- Overrides
PYTHONPATHin the subprocess environment. - Sets
cwdto the workspace root unless explicitly overridden. - Does NOT pick up per-folder
python.defaultInterpreterPathor env activation from a subfolder.vscode/settings.json.
Result: imports that resolve in a terminal fail in the debugger with ModuleNotFoundError, because debugpy's path injection shadows the manually set PYTHONPATH.
Steps to Reproduce
- Monorepo:
C:\D\workspace\packages\api\src\api\__init__.py launch.json:{ "type": "python", "module": "api.main", "cwd": "${workspaceFolder}/packages/api", "env": { "PYTHONPATH": "${workspaceFolder}/packages/api/src" } }- Terminal run:
cd packages/api && python -m api.main— works. - F5 debug:
ModuleNotFoundError: No module named 'api'.
Expected
- debugpy should merge the user-specified
env.PYTHONPATHwith (not replace) its own injected paths. - Or: document precisely which env vars debugpy overwrites so
launch.jsonauthors can compensate.
Related
- #2002 (nested subprocess module resolution) — same root cause, different trigger path
- Dominant language
- Python
- Stars
- 2.5k
- Forks
- 202
- Avg merge
- 5d 1h
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/debugpy
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
All issues in microsoft/debugpy
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
learningequality/ricecooker#747 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
run-llama/llama_index#23199 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
KhronosGroup/glTF-Blender-IO#2769 ·