Open weikanglim opened 2 years ago
Without supporting additional features, the simplest way is to avoid the hang and fail fast by configuring git
to run clone
non-interactively via the following env variables, and then translate the git
output and provide an error message that helps the user proceed. Translation of error messages can easily be done based on the sample outputs below:
# Disable stdin for SSH
export GIT_SSH_COMMAND='ssh -oBatchMode=yes'
# Disable git terminal prompt
export GIT_TERMINAL_PROMPT=0
# Disable stdin for SSH
export GIT_SSH_COMMAND='ssh -oBatchMode=yes'
# Disable git terminal prompt
export GIT_TERMINAL_PROMPT=0
root@weilim-z4:~# azd init --template git@github.com:Azure-Samples/todo-python-mongo.git
Initializing a new project in /root
Error: fetching template: failed to clone repository git@github.com:Azure-Samples/todo-python-mongo.git, exit code: 128, stdout: , stderr: Cloning into '/tmp/az-dev-template4076525733'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
: exit status 128
root@weilim-z4:~# azd init
Initializing a new project in /root
? Select a project template Azure-Samples/todo-python-mongo
Error: fetching template: failed to clone repository https://github.com/Azure-Samples/todo-python-mongo, exit code: 128, stdout: , stderr: Cloning into '/tmp/az-dev-template3897856328'...
fatal: could not read Username for 'https://github.com': terminal prompts disabled
: exit status 128
# After host verification is performed, ssh key denied
root@weilim-z4:~# azd init --template git@github.com:Azure-Samples/todo-python-mongo.git
Initializing a new project in /root
Error: fetching template: failed to clone repository git@github.com:Azure-Samples/todo-python-mongo.git, exit code: 128, stdout: , stderr: Cloning into '/tmp/az-dev-template1501941468'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
: exit status 128
Not a must-fix for Release 0.2. Keeping it in Backlog.
I am running into this now with WSL - Ubuntu 20.04 as well.
@weikanglim I can't repro this anymore. Is this still any issue?
@savannahostrowski I think this can still happen if trying to azd init
from a repository that isn't public and requires auth.
Yeah - can confirm. That's still the case.
Output from
azd version
Runazd version
and copy and paste the output here: root@weilim-z4:~/todo-python-mongo# azd version azd version 0.0.1-beta.1699350 (commit 17408687d1ec2ccb7dcbdb387811cd6159ba323f)Describe the bug Linux: without first setting up non-interactive credentials (SSH key or cached tokens) to the repository, run
azd init
To Reproduce
Run
azd init
(debug flag used below, but not necessary for repro)Expected behavior
git clone
should either fail the command on interactive prompt, or display the promptEnvironment Information on your environment:
Additional context N/A