Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug code in VSCode dev container #36

Closed
KThaulow opened this issue Apr 26, 2024 · 2 comments
Closed

Debug code in VSCode dev container #36

KThaulow opened this issue Apr 26, 2024 · 2 comments

Comments

@KThaulow
Copy link
Contributor

Version of the custom_component

Latest version of master

Configuration

Describe your configuration here.

VSCode on M2 (Apple Silicon)

Describe the bug

Thank you for this great integration!
I'm trying to contribute to the code, but I'm unable to attach the debugger to the task.

The steps I'm using:

  1. Fork the repo and start the dev container
  2. Run the task "Run Home Assistant on port 8123"
  3. Call "Remote Python Debugger: Start" in HA Service Calls
  4. In the terminal, I'm not getting "It seems that frozen modules are being used..."

When running the "Python: Attach Local" launch, the debugger starts but I'm unable to hit any breakpoints. E.g. a breakpoint under custom_components/heru/switch.py. When modifying the code and restarting the task, I can see that the debug logs are getting updated with the new code.

I suspect that the code that is being run is the copied code under .devcontainer/hass/custom_components/heru/switch.py instead of custom_components/heru/switch.py.

I've tried to update the .devcontainer to use:
"image": "mcr.microsoft.com/vscode/devcontainers/python:0-3.11-bullseye"
and "remoteUser": "vscode" but that didn't help.

Can you help me figure out what I'm missing to be able to debug the code?

Thanks!

Debug log


0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
2024-04-26 09:21:12.201 WARNING (MainThread) [homeassistant.components.debugpy] Waiting for remote debug connection on 0.0.0.0:5678
2024-04-26 09:21:21.974 WARNING (MainThread) [homeassistant.setup] Setup of debugpy is taking over 10 seconds.

@toringer
Copy link
Owner

Have the same problem myself, even after updating the devcontainer to the latest HA and python 3.12.

Found this, but not sure if it is related.

@KThaulow
Copy link
Contributor Author

I also found that post, but I'm not sure how to proceed from here.

I tried to launch your code directly in the debugger instead of attaching the debugger, by adding this to launch.json

{
      "name": "Home Assistant",
      "type": "debugpy",
      "request": "launch",
      "module": "homeassistant",
      "justMyCode": false,
      "args": [
        "--debug",
        "-c",
        "config"
      ]
    }

However, I'm getting errors when doing so:

Exception has occurred: FileNotFoundError
[Errno 2] No such file or directory: '/usr/local/lib/python311.zip'

I'm fairly new to HA and dev containers, but I'll see if I can get that working instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants