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
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”:
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",
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.