Commit abf6d9b
committed
fix: bind the ssh agent socket from $SSH_AUTH_SOCK, not a guess at its path
`devpod up` refused the create outright on a host whose agent is not a
hand-rolled symlink:
devcontainer up: runner run container: bind mount source path does not
exist /home/kinisi/.ssh/agent.sock
The manifest bound ${localEnv:HOME}/.ssh/agent.sock and said so in a comment
calling it "an assumption -- stock OpenSSH puts its agent socket in /tmp --
but a pre-existing one, since containerEnv already hardcodes the same path".
The assumption is false for every agent that picks its own path: gpg-agent,
which is what a YubiKey OpenPGP setup gives you, listens on
$XDG_RUNTIME_DIR/gnupg/S.gpg-agent.ssh; ssh-agent(1) on a /tmp/ssh-XXXX
mktemp path; 1Password and gnome-keyring on paths of their own. None is under
~/.ssh, so the failure lands before the container exists and reads as a
broken tool rather than as this repository naming a path the host never had.
The reverse of the old comment's argument is what the fix rests on:
containerEnv hardcodes the *target*, and that stays hardcoded. Inside the
container SSH_AUTH_SOCK is /home/vscode/.ssh/agent.sock whatever the host
called it, so the source is the only half that has to vary.
init-host.sh cannot paper over this the way it does for known_hosts, which it
touches into existence: there is no touching a socket into being an agent.
What it can do is heal a stale one, and that list named the path the manifest
used to bind, so it moves too -- via $SSH_AUTH_SOCK with the old path kept
beside it, since a container created before this change still has a stale
mount at the old name. Run inside a container this repo built, $SSH_AUTH_SOCK
is the container path, which is exactly the mount that can be stale there: the
variable is the right name at both ends, where the literal was only ever right
by coincidence.
Two costs, both real and neither hidden. An unset SSH_AUTH_SOCK expands to
nothing and the mount is malformed rather than skipped, because
devcontainer.json has no conditional mounts -- a host with no agent at all was
already broken here and is now broken differently. And this is a change under
.devcontainer/, so the prebuild tag moves: every launch builds locally until
devcontainer-prebuild.yml republishes on main.
Two guards, because the target path and the heal list are hand-maintained
copies of the mount source and both had already drifted from it:
test_the_agent_socket_is_bound_from_the_variable_that_names_it and
test_the_host_hook_heals_the_socket_it_is_mounted_from. Both fail against the
old manifest.1 parent 4af27b3 commit abf6d9b
3 files changed
Lines changed: 81 additions & 5 deletions
File tree
- .devcontainer
- claude-code
- test/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
123 | 133 | | |
124 | 134 | | |
125 | | - | |
| 135 | + | |
| 136 | + | |
126 | 137 | | |
127 | 138 | | |
128 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
127 | 150 | | |
128 | 151 | | |
129 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
681 | 681 | | |
682 | 682 | | |
683 | 683 | | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
0 commit comments