Developing Home Assistant Core in a VSCode Devcontainer

I would have to build it out to determine the mounts path for you - but if you use my edited devcontainer.json above that makes the environment trusted then once the repo is cloned locally you can edit both your personal repo and the custom one in the same vscode (thing you need to restart the vscode after rebuilding the container the first time)

I’ll try to find time to do the above over the next day or so and provide some steps for this scenario.

Yes this is the way I do my custom components too - build out the container as I described above and then open the repo locally in another vscode when it comes time to commuting the changes

This seems to be a better way, thank you, I just have to study how it works; for example I don’t see the Tasks file to map to the VS hotkeys and the scripts seem “scattered”.

Mmm, doesn’t seem so. Whenever I open the Home Assistant devcontainer that becomes the root of the VS Code tree. Then I have the hotkeys and tasks to run HA (i.e. F5) and the on-save linting, but on the entire fork of course. My custom component gets mounted on /config/custom_components/domain but I don’t get the git commits list, differences, branches and so on in that window.
Maybe it is a problem just mine, but I don’t really like to work this way… If the HACS solution works it would be certainly better.

Hi @Kingy444!

I’ve been trying to follow your steps for developing home assistant inside devcontainer since yesterday but I keep getting stuck with an error when trying to mount a local path inside the container.

I have followed steps 1 through 5 from Set up development environment | Home Assistant Developer Docs and that works fine.

But when I add a mounts section like the following:

"mounts": [
    // Custom component
"source=/home/gcirne/Projects/blah,target=${containerWorkspaceFolder}/config/custom_components/blah,type=bind",
]

I keep getting the following error:

docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /home/gcirne/Projects/blah.

I have tripled checked and the source path exists on my machine…

Any tips or pointers on what I could try?

Mine is on windows so im not sure - but im guessing that maybe /home is confused on whether you want to use /home within the container or the local machine. I would try ${localEnv:HOME} instead

I had already tried ${localEnv:HOME}… same error unfortunately. But thanks anyway!