No support for per-subpackage launch.json + in monorepo: debugger breaks imports that terminal run resolves
还没有人认领这个 Issue。
评估
调研方向
首先复现所提供的 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 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
- 主要语言
- Python
- 星标
- 2.5k
- 派生
- 208
- 平均合并
- 1 天 43 分钟
- 30 天内合并 PR
- 6
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/debugpy 的其他 Issue
-
pydevd_comm.py start_client() does not set TCP_NODELAY on the connections it opens可能已有人在做 @nightcityblade 于 56 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
-
Document "rules"-option可能已有人在做 @nightcityblade 于 44 天前认领。 未关闭documentation
难度 2/5 1-3 小时 新手友好度 68/100
-
wx.EventLoop() deprecation warning可能已有人在做 @nightcityblade 于 43 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
-
debugpy.configure(python=) is not properly documented可能已有人在做 @nightcityblade 于 54 天前认领。 未关闭documentation
难度 2/5 1-3 小时 新手友好度 62/100
-
难度 5/5 一周以上 新手友好度 15/100
查看 microsoft/debugpy 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
NousResearch/hermes-agent#136483 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
[BUG] LazyStackedTensorDictStore zeroes the last byte of a new key set on the last element可能已有人在做 @peterdsharpe 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
pytorch/tensordict#2307 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
GrokModel.generate/a_generate pass an OpenAI-style list-of-dicts to xai_sdk.chat.user(), so every call crashes with a protobuf TypeError before any network I/O可能已有人在做 @Christian-Sidak 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
confident-ai/deepeval#3436 · 1 条评论 ·
维护者通常 1 天内回复