From eafc7fc53130dcaa3afac92773eed2fa6a30e498 Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Wed, 28 Nov 2018 12:28:21 -0600 Subject: [PATCH] require git when trying to use it in ansible-galaxy cli (#49212) * require git when trying to use it in ansible-galaxy cli Previously we weren't setting `required=True` when calling `get_bin_path` and the path would return `None`, this would cause a traceback when attempting to ' '.join() to create a string representation of the failed command for error output Fixes #49200 Signed-off-by: Adam Miller * add changelog Signed-off-by: Adam Miller (cherry picked from commit 81540bd754e8f96857057e3391f0d299273ebec2) --- changelogs/fragments/49212-require-git-ansible-galaxy.yaml | 2 ++ lib/ansible/playbook/role/requirement.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/49212-require-git-ansible-galaxy.yaml diff --git a/changelogs/fragments/49212-require-git-ansible-galaxy.yaml b/changelogs/fragments/49212-require-git-ansible-galaxy.yaml new file mode 100644 index 0000000000..62bf5058c8 --- /dev/null +++ b/changelogs/fragments/49212-require-git-ansible-galaxy.yaml @@ -0,0 +1,2 @@ +minor_changes: + - "ansible-galaxy: properly warn when git isn't found in an installed bin path instead of traceback" diff --git a/lib/ansible/playbook/role/requirement.py b/lib/ansible/playbook/role/requirement.py index 764d0c591f..764b302281 100644 --- a/lib/ansible/playbook/role/requirement.py +++ b/lib/ansible/playbook/role/requirement.py @@ -159,7 +159,7 @@ class RoleRequirement(RoleDefinition): raise AnsibleError("- scm %s is not currently supported" % scm) try: - scm_path = get_bin_path(scm) + scm_path = get_bin_path(scm, required=True) except (ValueError, OSError, IOError): raise AnsibleError("could not find/use %s, it is required to continue with installing %s" % (scm, src))