ansible-galaxy - add pre-release hint to dependency resolution error (#81147)

* add pre-release hint to dependency resolution error if --pre wasn't provided

Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
pull/81171/head
Sloane Hertel 1 year ago committed by GitHub
parent f1ddcb4ae4
commit 73dde45f0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
minor_changes:
- ansible-galaxy - add note to the collection dependency resolver error message about pre-releases if ``--pre`` was not provided (https://github.com/ansible/ansible/issues/80048).

@ -1809,6 +1809,11 @@ def _resolve_depenency_map(
elif not req.specifier.contains(RESOLVELIB_VERSION.vstring):
raise AnsibleError(f"ansible-galaxy requires {req.name}{req.specifier}")
if allow_pre_release:
pre_release_hint = ''
else:
pre_release_hint = 'Hint: Pre-releases are not installed by default unless the specific version is given. To enable pre-releases, use --pre.'
collection_dep_resolver = build_collection_dependency_resolver(
galaxy_apis=galaxy_apis,
concrete_artifacts_manager=concrete_artifacts_manager,
@ -1844,6 +1849,7 @@ def _resolve_depenency_map(
),
conflict_causes,
))
error_msg_lines.append(pre_release_hint)
raise AnsibleError('\n'.join(error_msg_lines)) from dep_exc
except CollectionDependencyInconsistentCandidate as dep_exc:
parents = [
@ -1870,6 +1876,7 @@ def _resolve_depenency_map(
error_msg_lines.append(
'* {req.fqcn!s}:{req.ver!s}'.format(req=req)
)
error_msg_lines.append(pre_release_hint)
raise AnsibleError('\n'.join(error_msg_lines)) from dep_exc
except ValueError as exc:

@ -1,5 +1,5 @@
# resolvelib>=0.6.0 added an 'incompatibilities' parameter to find_matches
# If incompatibilities aren't removed from the viable candidates, this example causes infinite resursion
# If incompatibilities aren't removed from the viable candidates, this example causes infinite recursion
- name: test resolvelib removes incompatibilites in find_matches and errors quickly (prevent infinite recursion)
block:
- name: create collection dir

@ -165,6 +165,9 @@
failed_when:
- '"Could not satisfy the following requirements" not in fail_dep_mismatch.stderr'
- '" fail_dep2.name:<0.0.5 (dependency of fail_namespace.fail_collection:2.1.2)" not in fail_dep_mismatch.stderr'
- 'pre_release_hint not in fail_dep_mismatch.stderr'
vars:
pre_release_hint: 'Hint: Pre-releases are not installed by default unless the specific version is given. To enable pre-releases, use --pre.'
- name: Find artifact url for namespace3.name
uri:

Loading…
Cancel
Save