Skip to content

Commit 8c35b23

Browse files
authored
Mac: Nice warning if you don't have an identity (#637)
Supporting `--all` on mac is "fun" because we rely on ssh auth and, unlike Linux's lovely bind mounts, macOS can't share the ssh authorization directly. Instead we have to carefully bounce the ssh authorization into the container by `ssh`ing into it. One of the steps in this process requires that the user has an ssh identity configured with their agent. This is fairly easy to do, but if you haven't done it the error message was garbage. This catches the original message from `ssh-add` and sends the user a nicer one that includes a link to instructions.
1 parent 6320aa7 commit 8c35b23

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

build_docs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import time
3737
import webbrowser
3838

3939
DOCKER_BUILD_QUIET_TIME = 3 # seconds
40+
SSH_AGENT_HELP = 'https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent' # noqa
4041

4142
DIR = dirname(realpath(__file__))
4243
logger = logging.getLogger('build_docs')
@@ -250,6 +251,10 @@ def forward_ssh_auth_into_container(container, docker_run):
250251
handle_popen(get_ssh_public_key, record_public_key)
251252
keys = "\n".join(public_keys) + "\n"
252253
if get_ssh_public_key.returncode != 0:
254+
if 'The agent has no identities.' in keys:
255+
raise ArgError('--all requires an identity be registered with the '
256+
'ssh-agent on macOS. See ' + SSH_AGENT_HELP + ' '
257+
'for instructions.')
253258
raise subprocess.CalledProcessError(get_ssh_public_key.returncode,
254259
cmd, keys)
255260

@@ -451,6 +456,8 @@ if __name__ == '__main__':
451456
exit(1)
452457
except subprocess.CalledProcessError as e:
453458
print(e)
459+
if e.output:
460+
print(e.output)
454461
exit(e.returncode)
455462
except KeyboardInterrupt:
456463
# Just quit if we get ctrl-c

0 commit comments

Comments
 (0)