Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#2,047 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
python, vscode
领域
devtools

调研方向

首先复现所提供的 monorepo 布局和 launch.json,然后比较 Terminal 与 F5 子进程的环境,包括 cwd 和 PYTHONPATH。跟踪 debugpy 在启动时对环境和路径的处理;当用户路径得到保留,或被覆盖的变量已得到准确记录,并且所提供的模块启动不再失败时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

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
主要语言
Python
星标
2.5k
派生
208
平均合并
1 天 43 分钟
30 天内合并 PR
6

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/debugpy 的其他 Issue

查看 microsoft/debugpy 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。