{"record":{"id":"aa350139c9815ced","repo":"ansible/ansible","slug":"collection-requirement-at-path-s-has-both-a-m","errorCode":null,"errorMessage":"Collection requirement at '{path!s}' has both a {manifest_json!s} file and a {galaxy_yml!s}.\nThe requirement must either be an installed collection directory or a source collection directory, not both.","messagePattern":"Collection requirement at '(.+?)' has both a (.+?) file and a (.+?)\\.\nThe requirement must either be an installed collection directory or a source collection directory, not both\\.","errorType":"exception","errorClass":"AnsibleError","httpStatus":null,"severity":"error","filePath":"lib/ansible/galaxy/dependency_resolution/dataclasses.py","lineNumber":414,"sourceCode":"                    '{extra_tip!s}'.format(extra_tip=tip),\n                )\n\n        if req_type is None:\n            if _is_git_url(src_path):\n                req_type = 'git'\n                req_source = src_path\n            elif _is_http_url(src_path):\n                req_type = 'url'\n                req_source = src_path\n            elif _is_file_path(src_path):\n                req_type = 'file'\n                req_source = src_path\n            elif _is_collection_dir(src_path):\n                if _is_installed_collection_dir(src_path) and _is_collection_src_dir(src_path):\n                    # Note that ``download`` requires a dir with a ``galaxy.yml`` and fails if it\n                    # doesn't exist, but if a ``MANIFEST.json`` also exists, it would be used\n                    # instead of the ``galaxy.yml``.\n                    raise AnsibleError(\n                        u\"Collection requirement at '{path!s}' has both a {manifest_json!s} \"\n                        u\"file and a {galaxy_yml!s}.\\nThe requirement must either be an installed \"\n                        u\"collection directory or a source collection directory, not both.\".\n                        format(\n                            path=to_text(src_path, errors='surrogate_or_strict'),\n                            manifest_json=to_text(_MANIFEST_JSON),\n                            galaxy_yml=to_text(_GALAXY_YAML),\n                        )\n                    )\n                req_type = 'dir'\n                req_source = src_path\n            elif _is_collection_namespace_dir(src_path):\n                req_name = None  # No name for a virtual req or \"namespace.\"?\n                req_type = 'subdirs'\n                req_source = src_path\n            else:\n                raise AnsibleError(  # NOTE: this is never supposed to be hit\n                    'Failed to automatically detect the collection '","sourceCodeStart":396,"sourceCodeEnd":432,"githubUrl":"https://github.com/ansible/ansible/blob/9cf16a4aca7898481c257f1e17ad28d0b67b1f85/lib/ansible/galaxy/dependency_resolution/dataclasses.py#L396-L432","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# dir is both source and installed -> make it a pure source dir\nrm ./my_collection/MANIFEST.json\nansible-galaxy collection install ./my_collection","handlingStrategy":"validation","validationCode":"import os\n\ndef validate_collection_dir(path):\n    has_manifest = os.path.isfile(os.path.join(path, 'MANIFEST.json'))\n    has_galaxy = os.path.isfile(os.path.join(path, 'galaxy.yml'))\n    if has_manifest and has_galaxy:\n        raise SystemExit(f'{path}: contains both MANIFEST.json and galaxy.yml; keep exactly one')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never extract built artifacts into the source checkout","Keep build outputs (dist/) excluded from directories referenced as requirements sources"],"tags":["collections","requirements","filesystem","metadata"],"backgroundTag":null,"analyzedSha":"9cf16a4aca7898481c257f1e17ad28d0b67b1f85","analyzedAt":"2026-08-15T00:15:47.100Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}