ansible/ansible · error · AnsibleError
Collection requirement at '{path!s}' has both a {manifest_js
Error message
Collection requirement at '{path!s}' has both a {manifest_json!s} file and a {galaxy_yml!s}.
The requirement must either be an installed collection directory or a source collection directory, not both. What it means
Raised in Requirement.from_requirement_dict (lib/ansible/galaxy/dependency_resolution/dataclasses.py) when a directory requirement contains BOTH MANIFEST.json and galaxy.yml. MANIFEST.json marks an installed (built) collection dir; galaxy.yml marks a source dir. Ansible refuses to guess which representation to use, because build/download would use MANIFEST.json while source semantics expect galaxy.yml.
Source
Thrown at lib/ansible/galaxy/dependency_resolution/dataclasses.py:414
'{extra_tip!s}'.format(extra_tip=tip),
)
if req_type is None:
if _is_git_url(src_path):
req_type = 'git'
req_source = src_path
elif _is_http_url(src_path):
req_type = 'url'
req_source = src_path
elif _is_file_path(src_path):
req_type = 'file'
req_source = src_path
elif _is_collection_dir(src_path):
if _is_installed_collection_dir(src_path) and _is_collection_src_dir(src_path):
# Note that ``download`` requires a dir with a ``galaxy.yml`` and fails if it
# doesn't exist, but if a ``MANIFEST.json`` also exists, it would be used
# instead of the ``galaxy.yml``.
raise AnsibleError(
u"Collection requirement at '{path!s}' has both a {manifest_json!s} "
u"file and a {galaxy_yml!s}.\nThe requirement must either be an installed "
u"collection directory or a source collection directory, not both.".
format(
path=to_text(src_path, errors='surrogate_or_strict'),
manifest_json=to_text(_MANIFEST_JSON),
galaxy_yml=to_text(_GALAXY_YAML),
)
)
req_type = 'dir'
req_source = src_path
elif _is_collection_namespace_dir(src_path):
req_name = None # No name for a virtual req or "namespace."?
req_type = 'subdirs'
req_source = src_path
else:
raise AnsibleError( # NOTE: this is never supposed to be hit
'Failed to automatically detect the collection 'View on GitHub (pinned to 9cf16a4aca)
Solutions
- Decide the dir's role: for a source dir, delete MANIFEST.json; for an installed dir, delete galaxy.yml
- Keep build output out of the source tree (build into dist/ and extract/install elsewhere)
- If both are legitimately needed, use two separate directories and reference each explicitly
Example fix
# dir is both source and installed -> make it a pure source dir rm ./my_collection/MANIFEST.json ansible-galaxy collection install ./my_collection
Defensive patterns
Strategy: validation
Validate before calling
import os
def validate_collection_dir(path):
has_manifest = os.path.isfile(os.path.join(path, 'MANIFEST.json'))
has_galaxy = os.path.isfile(os.path.join(path, 'galaxy.yml'))
if has_manifest and has_galaxy:
raise SystemExit(f'{path}: contains both MANIFEST.json and galaxy.yml; keep exactly one') Prevention
- Never extract built artifacts into the source checkout
- Keep build outputs (dist/) excluded from directories referenced as requirements sources
When it happens
Trigger: Pointing ansible-galaxy at a directory (type: dir or auto-detected from an existing path) that contains both files — typically a source checkout into which a built artifact was extracted, or a copy of an installed collection_dir combined with the original galaxy.yml.
Common situations: Developers building a collection in-place (`ansible-galaxy collection build` artifacts extracted into the repo); CI caches merging installed collections with source checkouts; copying an installed collection dir over a source dir.
Related errors
- The requirements file '%s' does not exist.
- Expecting requirements file to be a dict with the key 'colle
- Invalid offline source info for {namespace}.{name}:{version}
- Neither the collection requirement entry key 'name', nor 'so
- The collection requirement entry key 'type' must be one of f
AI-assisted analysis of ansible/ansible@9cf16a4aca (2026-08-15).
Data as JSON: /api/errors/aa350139c9815ced.
Report an issue: GitHub.