Problems setting up addons devcontainer

I have been having issues trying to configure the devcontainer for testing a custom addon following the steps outlined here.

However when I try to open the container i get the following message

[6894 ms] Start: Run in container: /bin/sh -c bash devcontainer_bootstrap
rm: remove write-protected regular file '/etc/machine-id'? y
rm: cannot remove '/etc/machine-id': Permission denied
[12257 ms] postStartCommand failed with exit code 1. Skipping any further user-provided commands.
Done. Press any key to close the terminal.

Also failing if I answer to the rm command in the negative

[8644 ms] Start: Run in container: /bin/sh -c bash devcontainer_bootstrap
rm: remove write-protected regular file '/etc/machine-id'? n
update-alternatives: using /usr/sbin/iptables-legacy to provide /usr/sbin/iptabl
es (iptables) in manual mode
update-alternatives: error: error creating symbolic link '/etc/alternatives/ipta
bles.dpkg-tmp': Permission denied
Fails adjust iptables
update-alternatives: using /usr/sbin/ip6tables-legacy to provide /usr/sbin/ip6ta
bles (ip6tables) in manual mode
update-alternatives: error: error creating symbolic link '/etc/alternatives/ip6t
ables.dpkg-tmp': Permission denied
Fails adjust ip6tables
chmod: changing permissions of '/usr/bin/ha': Operation not permitted
[13521 ms] postStartCommand failed with exit code 1. Skipping any further user-provided commands.
Done. Press any key to close the terminal.

The same error occurs on both Windows 11 and Ubuntu 22.04.1. Below is the structure of my devcontainer folder
Screenshot 2022-10-15 222138

Can anyone see where I may have went wrong?

Many thanks

Same issue here, just started working on my first addon and ran into the exact same permissions errors. I’m on a Mac on the latest OS.

Same thing with me using the below:

  • Windows 11
  • Docker Desktop 4.10.1 (82475) on WSL
  • VS Code 1.72.2

I have the same issue too.
VSCode on Win10 + Docker Desktop on WSL2 backend

Can’t say it’s “right” – but its let me move forward.

Just add sudo to the postStartCommand in the .devcontainers.json

 "postStartCommand": "sudo bash devcontainer_bootstrap",

I had to do the same where “start home assistant” is defined in tasks.yaml

        "command": "sudo supervisor_run",

We’ll see if I actuallymake it past seeing this in my browser…

Same issue over here. Anybody find a solution without involving sudo ?

I tried on windows 11 and github codespace

I have the same error, and sudo didn’t help. Following the exact same instructions from the official add-ons development page, and nothing worked.

This seems to work for me:
chmod +x /usr/bin/supervisor_run

Not the “correct” way either, but this is what worked for me after numerous rounds of testing.

You need to do both of the above along with the following additional flag so that your addons show up in the HA local addons directory which won’t happen without the “-E”:

"postStartCommand": "sudo -E bash devcontainer_bootstrap",
"command": "sudo chmod a+x /usr/bin/supervisor* && sudo -E supervisor_run",

The above worked and I was able to do real-time modifications and testing of my addon within the devcontainer.

2 Likes

I’m running into the same problem.
Where exactly do these commands go?
in the .devcontainer.json wich already includes

    "postStartCommand": "bash devcontainer_bootstrap",
    "runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"],

or .vscode/tasks.json?

i fixed the initial zsh:1: permission denied: supervisor_run by manually running sudo chmod +x /usr/bin/supervisor_run

could you share more details on your setup and how you’re able to do real-time modifications and testing of your add-on within the devcontainer?

EDIT: i figured it out:
in .devcontainer
"postStartCommand": "bash devcontainer_bootstrap",
is replaced by
"postStartCommand": "sudo -E bash devcontainer_bootstrap",

in .vscode/tasks.json
"command": "supervisor_run",
is replaced by
"command": "sudo chmod a+x /usr/bin/supervisor* && sudo -E supervisor_run",

4 Likes

@afiwube, your local add-on now shows up in the devcontainer HA instance, correct?

yes, it does! though I have to install it

Right, that’s normal. Whenever you make any changes to the add-on code, all you need to do is hit “Rebuild” in your add-on to pickup the code changes as long as you are doing the local build option during development.

1 Like