diff --git a/docs/devcontainer.md b/docs/devcontainer.md index 99c4ece14..42fd315f6 100644 --- a/docs/devcontainer.md +++ b/docs/devcontainer.md @@ -33,6 +33,8 @@ The host SSH key, allowed-signers file, and `gh` config directory are mounted in | `~/.config/git/allowed_signers` | `/home/vscode/.config/git/allowed_signers` | read-only | Maps your email to your public key so `git verify-commit` and `git log --show-signature` work inside the container. | | `~/.config/gh` | `/home/vscode/.config/gh` | read-write | `gh` CLI auth state shared with the host. See [`gh` credential store][gh-credential-store] below. | +Each mount's `source` finds the host home directory by joining `${localEnv:HOME}${localEnv:USERPROFILE}`, so exactly one of those variables must be set. Each host path must also exist under that directory, since Docker refuses an absent one inside WSL2. See [Troubleshooting][troubleshooting] for a native Windows launch. + VS Code Dev Containers automatically copies your host `~/.gitconfig` into the container at startup. So `user.name`, `user.email`, `user.signingkey`, `gpg.format`, and `commit.gpgsign` propagate without an explicit mount. The SSH agent is forwarded automatically by the Dev Containers extension via `SSH_AUTH_SOCK`. So signing works as long as the agent on the host has your key loaded. @@ -100,6 +102,10 @@ If `git -c gpg.format=ssh commit -S` errors with `signing failed: no allowed sig ## Troubleshooting +**Container fails to start on Windows with `The filename, directory name, or volume label syntax is incorrect`.** A launch with both `HOME` and `USERPROFILE` set joins them into an invalid bind-mount path. VS Code launched from Git Bash can inherit `HOME`, and a `HOME` variable set in the Windows environment reaches a Start menu launch too. `devcontainer.json` substitution has no fallback that picks one of them. The supported route is opening the repo from inside a WSL2 distribution, where each host path must exist under the WSL2 home. + +A native launch opens the repo from Windows, even with Docker Desktop's WSL2 backend, and is outside that route. It needs `HOME` absent from VS Code's environment. Close every VS Code window, then launch VS Code from the Start menu. Where a `HOME` is set in the Windows environment, run `Remove-Item Env:HOME` in PowerShell, then `code .` from that session instead. Each host path must also exist under `%USERPROFILE%`. On Docker Desktop's WSL2 backend, an absent one becomes an empty host directory and the container still starts, even for a key file. Such a directory blocks the host setup steps that write that file. To recover, remove the container, delete that directory, and create the file. Then run **Dev Containers: Reopen in Container**. Windows `gh` defaults to `%AppData%\GitHub CLI` rather than `.config\gh`, so that mount can start empty and share no `gh` login. Evidence for a native launch is a devcontainer CLI `up` on Docker Desktop's WSL2 backend. It used scratch copies of the snippets, a synthetic home, and replaced image tags. So the VS Code launch, its `.gitconfig` copy, the lifecycle commands, and commit signing on a native launch are untested. + **Permission denied writing to `~/.ssh/known_hosts` in the container.** The `onCreateCommand` should have chowned `~/.ssh` to `vscode`. Rebuild the container, and if it persists, open a shell and run the same `sudo install -d -m 700 -o vscode -g vscode ~/.ssh` manually. **`git commit` fails with "no SSH agent socket".** VS Code Dev Containers forwards `SSH_AUTH_SOCK` automatically, but only if the host has `ssh-agent` running with at least one key. Run `ssh-add -l` on the host first, and if it says "could not open a connection to your authentication agent", start the agent (see [host setup][host-setup]). @@ -116,6 +122,7 @@ If `git -c gpg.format=ssh commit -S` errors with `signing failed: no allowed sig [devcontainer-2]: ../catalog/snippets/devcontainer/python/devcontainer.json [gh-credential-store]: #gh-credential-store [host-setup]: ./host-setup.md +[troubleshooting]: #troubleshooting diff --git a/docs/host-setup.md b/docs/host-setup.md index 5cfa3c7c3..d6b558da1 100644 --- a/docs/host-setup.md +++ b/docs/host-setup.md @@ -6,7 +6,7 @@ Supported hosts: - **Linux** - both the devcontainer flow and the host-install flow. - **macOS** - both the devcontainer flow and the host-install flow. -- **Windows** - the devcontainer flow requires **WSL2**, and native Windows (PowerShell + winget) is supported only for the host-install flow described in `README.md`. The bind-mounts in the `catalog/snippets/devcontainer/` definitions rely on POSIX paths and only work from Linux/macOS/WSL2. +- **Windows** - the supported devcontainer route is opening the repo from inside a **WSL2** distribution. Native Windows (PowerShell + winget) is supported for the host-install flow described in `README.md`. A native launch of a `catalog/snippets/devcontainer/` definition opens the repo from Windows instead, and has its own conditions, per [Devcontainer troubleshooting][devcontainer-troubleshooting]. > **Shell assumptions in this doc**: every command snippet below assumes a **POSIX shell** (bash/zsh) and POSIX path conventions (`~/.ssh/...`, `mkdir -p`, `$(...)` command substitution). A block marked `powershell` is the exception. Such a block is the **Windows-native** form of the step it sits in, meant to run in PowerShell rather than translated. On Windows, run the POSIX snippets from **WSL2** or **Git Bash**, since they will not work as-is in PowerShell or `cmd.exe`. The git config and `gh` commands are portable, and only the file and path manipulation differs by shell. @@ -406,6 +406,7 @@ A host that fails any row is not ready for the procedure that row names. The fix [bootstrap]: ../host-setup/bootstrap.sh [bootstrap-ps1]: ../host-setup/bootstrap.ps1 [devcontainer]: ./devcontainer.md +[devcontainer-troubleshooting]: ./devcontainer.md#troubleshooting [files]: ../spec/files.json [governance-git-and-commit-rules]: ../GOVERNANCE.md#git-and-commit-rules [host-gate]: ../scripts/host_gate.py diff --git a/docs/ssh-signing.md b/docs/ssh-signing.md index 922f9ca9f..f18700ed9 100644 --- a/docs/ssh-signing.md +++ b/docs/ssh-signing.md @@ -85,9 +85,9 @@ The Keychain prompt for the passphrase appears on first use after each reboot, a ### Windows (without WSL) -Native Windows is **not supported** for the devcontainer setup in this repo. Use WSL2 instead. The reason: VS Code Dev Containers needs a Linux-like file system for the bind-mounts to behave consistently. A second part of the reason is that Docker Desktop's WSL2 backend is the supported path. +The supported route for the devcontainer setup in this repo is opening it from inside a WSL2 distribution. A native Windows launch has its own conditions, per [Devcontainer troubleshooting][devcontainer-troubleshooting]. Commit signing inside a container started that way is untested. -If you must work on Windows directly without a devcontainer, OpenSSH for Windows can sign with `gpg.format=ssh`, but the bind-mounted devcontainer setup expects Linux/WSL2 paths. +If you must work on Windows directly without a devcontainer, OpenSSH for Windows can sign with `gpg.format=ssh`. ## Verify Signing @@ -116,11 +116,12 @@ If the container's `~/.ssh` directory exists with the wrong owner (root, surface **`signing failed: no allowed signers`.** The `allowed_signers` file exists but doesn't contain a line matching `user.email` + a key. Re-run `echo "$(git config --global user.email) namespaces=\"git\" $(cat ~/.ssh/id_ed25519.pub)" >> ~/.config/git/allowed_signers`. -**Verifies on the host but not in the container.** The bind-mount source path differs. `${localEnv:HOME}` resolves on Linux/macOS hosts, and on Windows hosts (WSL2 backend) the `${localEnv:USERPROFILE}` fallback in `devcontainer.json` handles it. Check the actual mount with `mount | grep ssh` inside the container. +**Verifies on the host but not in the container.** The bind-mount source path differs. Each `source` in `devcontainer.json` joins `${localEnv:HOME}${localEnv:USERPROFILE}`, which resolves where exactly one of them is set. That is `HOME` on Linux, macOS, and WSL2, and `USERPROFILE` on a native Windows launch. Check the actual mount with `mount | grep ssh` inside the container. **SSH agent says "could not open a connection".** The host's agent isn't running. Linux: `systemctl --user start ssh-agent.socket`. macOS: open a new terminal so launchd starts the agent. [devcontainer]: ./devcontainer.md +[devcontainer-troubleshooting]: ./devcontainer.md#troubleshooting [host-setup]: ./host-setup.md