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

Breakpoint set in source code are not hit when attaching to a devcontainer process

Đang mở
#1,538 0 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
42/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
devtools

Hướng nghiên cứu

Bắt đầu với các cấu hình Python: Attach LocalPython: Attach Remote trong launch.json, sau đó chạy scripts/develop và tái hiện quy trình attach trong môi trường devcontainer được liệt kê. So sánh hành vi trước và sau khi gọi debugpy.breakpoint(); được xem là hoàn tất khi các breakpoint mã nguồn được đặt trong giao diện người dùng VS Code được hit trong quá trình attach mà không cần breakpoint thủ công đó.

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

Mô tả

bug

Not sure if this issue relates to this repository or would maybe better fit in main VSCode repo. Or maybe in VSCode python debugger extension.

Environment data

  • debugpy version: 1.8.1
  • OS and version: Debian 12 (bookworm) (container image: mcr.microsoft.com/devcontainers/python:3.12)
  • Python version: 3.12.2
  • Using VS Code or Visual Studio: VSCode with devcontainer
  • VSCode: 1.87.1
  • Python debugger (VSCode extension): v2024.2.0

Actual behavior

Breakpoints (set in source code) are not hit after attaching the debugger to the process under development in devcontainer.

The development environment has different launch.json configurations.
They were updated to "type": "debugpy" following deprecation warnings and trying to overcome this issue (they were "type": "python" before) but the issue is the same whatever this setting.

Launch configurations for launching and debugging a python process (i.e. the "request": "launch") work correctly. Just the "request": "attach" to a running process doesn't hit the breakpoints.

I've enabled debugpy logs and looks as if the commands to set/enable/delete breakpoints are accepted correctly by the debug server (or whatever it is)

Also,
If I use:

import debugpy
debugpy.breakpoint()

in the process under debug, it works correctly (i.e. the debugger stops and waits for stepping or whatever any other debug action.

More important, after this invoked breakpoint, the breakpoints set in source code through the vscode UI start working correctly as if no issue were there (i.e. I can add delete disable breakpoints and they'll all work)

The issue started (without any configuration change in the development environment) around when installing latest vscode (I'm not sure if this also triggered updating any other component like debugpy and/or the debugpy vscode extension

Expected behavior

Having the breakpoints set in vscode UI source edit window work without any trick (manually invoking the debugpy.breakpoint() at least once)

Steps to reproduce:

This is my dev environment but beside installing, it would need some manual configuration of the process under debug (Home Assistant) before being able to predictably set any breakpoint.

  1. clone https://github.com/krahabb/meross_lan
  2. start the task "Run Home Assistant...."
  3. from 'Run and Debug' launch the 'Python: Attach local'

At any rate, these are key configurations of the dev environment:

"devcontainer.json"

{
    "name": "ludeeus/integration_blueprint/meross_lan",
    "image": "mcr.microsoft.com/devcontainers/python:3.12",
	"runArgs": [ "--network=host" ],
    "postCreateCommand": "scripts/setup",
    "customizations": {
        "vscode": {
            "extensions": [
                "ms-python.python",
                "ms-python.vscode-pylance"
            ],
            "settings": {
                "files.eol": "\n",
                "editor.tabSize": 4,
                "python.pythonPath": "/usr/local/bin/python3",
                "python.analysis.autoSearchPaths": false,
                "python.formatting.provider": "black",
                "python.formatting.blackPath": "/usr/local/py-utils/bin/black",
                "editor.formatOnPaste": false,
                "editor.formatOnSave": true,
                "editor.formatOnType": true,
                "files.trimTrailingWhitespace": true
				}
        }
    },
    "remoteUser": "root",
    "features": {
        "ghcr.io/devcontainers/features/rust:1": {}
    }
}

"settings.json"

{
    "files.associations": {
        "*.yaml": "home-assistant"
    },
    "python.analysis.typeCheckingMode": "basic",
    "python.analysis.diagnosticSeverityOverrides": {
        "reportShadowedImports": "none"
    },
    "python.analysis.extraPaths": [
        "./custom_components/meross_lan"
    ],
    "testing.defaultGutterClickAction": "debug",
    "python.testing.unittestEnabled": false,
    "python.testing.pytestEnabled": true,
    "python.testing.pytestArgs": [
        "tests"
    ],
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter"
    }
}

"launch.json"

{
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Emulator",
      "type": "debugpy",
      "request": "launch",
      "module": "aiohttp.web",
      "justMyCode": false,
      "args": [
        "-H",
        "127.0.0.1",
        "-P",
        "40000",
        "emulator:run",
        "emulator_traces",
        "-key pippo",
        "-broker localhost:8883",
        //"-uuid 01234567890123456789012345678901"
      ]
    },
    {
      // Example of attaching to local debug server
      "name": "Python: Attach Local",
      "type": "debugpy",
      "request": "attach",
      "connect": {
        "host": "localhost",
        "port": 5678
      },
      "justMyCode": false,
      "pathMappings": [
        {
          "localRoot": "${workspaceFolder}",
          "remoteRoot": "."
        }
      ]
    },
    {
      // Example of attaching to my production server
      "name": "Python: Attach Remote",
      "type": "debugpy",
      "request": "attach",
      "connect": {
        "host": "homeassistant.local",
        "port": 5678
      },
      "pathMappings": [
        {
          "localRoot": "${workspaceFolder}",
          "remoteRoot": "/usr/src/homeassistant"
        }
      ]
    },
    {
      "name": "Debug Tests",
      "type": "debugpy",
      "request": "launch",
      "program": "${file}",
      "purpose": [
        "debug-test"
      ],
      "env": {
        "PYTEST_ADDOPTS": "--no-cov"
      },
      "justMyCode": false
    },
    {
      "name": "Coverage",
      "type": "debugpy",
      "request": "launch",
      "module": "pytest",
      "args": [
        "--cov=custom_components/meross_lan",
        "--cov-report=html:htmlcov",
      ],
    }
  ]
}

"tasks.json"

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Run Home Assistant on port 8123",
            "type": "shell",
            "command": "scripts/develop",
            "problemMatcher": []
        }
     ]
}

"scripts/develop"

#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

# Create config dir if not present
if [[ ! -d "${PWD}/config" ]]; then
    mkdir -p "${PWD}/config"
    hass --config "${PWD}/config" --script ensure_config
fi

cp "${PWD}/.devcontainer/configuration.yaml" "${PWD}/config/configuration.yaml"

# Set the path to custom_components
## This let's us have the structure we want <root>/custom_components/integration_blueprint
## while at the same time have Home Assistant configuration inside <root>/config
## without resulting to symlinks.
export PYTHONPATH="${PYTHONPATH}:${PWD}/custom_components"

# Start Home Assistant
hass --config "${PWD}/config" --debug

Ngôn ngữ chính
Python
Star
2.5k
Fork
202
Merge trung bình
5 ngày 1 giờ
Pull request đã merge (30 ngày)
1

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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.