My project requires git access after the container is created, configured in the postCreateCommand hook. The git command fails as my SSH agent doesn't show up and thus git is not able to access the repository. If I comment the postCreateCommand hook definition and recreate the container, then it starts correctly, I can SSH into the container and successfully do a git fetch from there.
What did you expect to happen instead?
I expect to be able to run git commands that require SSH access from the postCreateCommand or postStartCommand lifecycle hooks using an SSH agent.
❯ devpod up git@github.com:ptab/reproduce-devpod-bug.git --ide none
…
info Run command : mkdir ~/.ssh && ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts && git fetch...
warn # github.com:22 SSH-2.0-babeld-4909cb0f2
warn git@github.com: Permission denied (publickey).
warn fatal: Could not read from remote repository.
warn
warn Please make sure you have the correct access rights
warn and the repository exists.
info lifecycle hooks: failed to run: mkdir ~/.ssh && ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts && git fetch, error: exit status 128
info devcontainer up: run agent command: Process exited with status 1
error Try using the --debug flag to see a more verbose output
fatal run agent command: Process exited with status 1
It doesn't seem to matter whether the repository is checked out locally or if the workspace is created directly from git, both options fail.
I also wondered if the type of hook definition mattered and so I tested all 3 options (string, array, object): all 3 failed. You can find all options I tried in the following my devcontainer.json:
What happened?
My project requires git access after the container is created, configured in the
postCreateCommand
hook. The git command fails as my SSH agent doesn't show up and thus git is not able to access the repository. If I comment thepostCreateCommand
hook definition and recreate the container, then it starts correctly, I can SSH into the container and successfully do a git fetch from there.What did you expect to happen instead?
I expect to be able to run git commands that require SSH access from the
postCreateCommand
orpostStartCommand
lifecycle hooks using an SSH agent.How can we reproduce the bug? (as minimally and precisely as possible)
I created a simple project to showcase the issue: https://github.com/ptab/reproduce-devpod-bug
It doesn't seem to matter whether the repository is checked out locally or if the workspace is created directly from git, both options fail. I also wondered if the type of hook definition mattered and so I tested all 3 options (string, array, object): all 3 failed. You can find all options I tried in the following my
devcontainer.json
:Local Environment:
DevPod Provider:
Anything else we need to know?
My SSH agent is 1Password for SSH & Git.