Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#2,047 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
python, vscode
Lĩnh vực
devtools

Hướng nghiên cứu

Bắt đầu bằng cách tái tạo bố cục monorepo và launch.json được cung cấp, sau đó so sánh môi trường của các subprocess Terminal và F5, bao gồm cwd và PYTHONPATH. Truy vết cách debugpy xử lý môi trường và đường dẫn khi khởi chạy; công việc được coi là hoàn tất khi các đường dẫn của người dùng được giữ nguyên hoặc các biến bị ghi đè được tài liệu hóa chính xác, đồng thời việc khởi chạy module được cung cấp không còn thất bại.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
Python
Star
2.5k
Fork
205
Merge trung bình
1 ngày 9 giờ
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/debugpy

Tất cả issue của microsoft/debugpy

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.