-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Description
The devcontainer setup scripts have two related issues with git/SSH/gh configuration inside the container:
-
Host-absolute paths in
.gitconfig:copy-host-user-conf.shexports the host's global git config verbatim, embedding host-specific absolute paths (e.g./Users/<user>/.ssh/id_ed25519_github.pub,/Users/<user>/.config/git/allowed-signers) and host-only entries (Homebrew credential helpers,core.excludesfile). These paths don't exist inside the container. -
Unreliable
postAttachCommand: All one-time setup (git config placement, SSH key copy, gh auth, pre-commit install) runs viapostAttachCommand, which is a known issue with Cursor (and sometimes VS Code) — it frequently doesn't fire, leaving the container without git config, SSH signing keys, or gh authentication.
Steps to Reproduce
- Run the install script:
curl -sSf .../install.sh | bash -s -- ~/my-project - Inspect
.devcontainer/.conf/.gitconfig— contains host-absolute paths - Open project in Cursor and reopen in container
- Check
ls /root/.ssh/— may only containknown_hosts(postAttachCommand didn't fire) - Check
git config user.signingkey— points to host path like/Users/.../id_ed25519_github.pub
Expected Behavior
.conf/.gitconfigshould contain container-appropriate paths (/root/.ssh/...,/root/.config/git/...)- Host-only entries (credential helpers, excludesfile, includeIf) should be stripped at export time
- One-time setup (git config, SSH keys, gh auth, pre-commit) should run reliably on container creation
- Only lightweight verification (SSH agent check, gh auth status) should depend on
postAttachCommand
Actual Behavior
.gitconfighas host paths that don't exist in the container- All setup depends on
postAttachCommandwhich frequently doesn't trigger in Cursor - Container may start without any git configuration, SSH keys, or gh authentication
Environment
- OS: macOS (Darwin 24.5.0)
- Container Runtime: Podman
- Editor: Cursor
- Image Version: latest
Possible Solution
- Fix
copy-host-user-conf.shawk block to rewrite paths and strip host-only entries at export time (fix at the source) - Refactor lifecycle: move one-time setup into
postCreateCommand, keep only auth verification inpostAttachCommand - Extract SSH agent + gh auth verification into a separate
verify-auth.shscript