Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

No support for per-subpackage launch.json + in monorepo: debugger breaks imports that terminal run resolves

Open
#2,047 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python, vscode
Domain
devtools

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 at packages/<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:

  1. Overrides PYTHONPATH in the subprocess environment.
  2. Sets cwd to the workspace root unless explicitly overridden.
  3. Does NOT pick up per-folder python.defaultInterpreterPath or 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
  1. Monorepo: C:\D\workspace\packages\api\src\api\__init__.py
  2. launch.json:
    {
      "type": "python",
      "module": "api.main",
      "cwd": "${workspaceFolder}/packages/api",
      "env": { "PYTHONPATH": "${workspaceFolder}/packages/api/src" }
    }
    
  3. Terminal run: cd packages/api && python -m api.main — works.
  4. F5 debug: ModuleNotFoundError: No module named 'api'.
Expected
  • debugpy should merge the user-specified env.PYTHONPATH with (not replace) its own injected paths.
  • Or: document precisely which env vars debugpy overwrites so launch.json authors 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/debugpy

All issues in microsoft/debugpy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.