{"record":{"id":"7ac7a1dbd3eedc95","repo":"nodejs/node","slug":"found-multiple-build-files-with-path-path","errorCode":null,"errorMessage":"Found multiple build files with path ${path}","messagePattern":"Found multiple build files with path (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/gyp/xcodeproj_file.py","lineNumber":1885,"sourceCode":"        for pbxbuildfile in self._properties.get(\"files\", []):\n            self._AddBuildFileToDicts(pbxbuildfile)\n\n    def FileGroup(self, path):\n        # Subclasses must override this by returning a two-element tuple.  The\n        # first item in the tuple should be the PBXGroup to which \"path\" should be\n        # added, either as a child or deeper descendant.  The second item should\n        # be a boolean indicating whether files should be added into hierarchical\n        # groups or one single flat group.\n        raise NotImplementedError(self.__class__.__name__ + \" must implement FileGroup\")\n\n    def _AddPathToDict(self, pbxbuildfile, path):\n        \"\"\"Adds path to the dict tracking paths belonging to this build phase.\n\n        If the path is already a member of this build phase, raises an exception.\n        \"\"\"\n\n        if path in self._files_by_path:\n            raise ValueError(\"Found multiple build files with path \" + path)\n        self._files_by_path[path] = pbxbuildfile\n\n    def _AddBuildFileToDicts(self, pbxbuildfile, path=None):\n        \"\"\"Maintains the _files_by_path and _files_by_xcfilelikeelement dicts.\n\n        If path is specified, then it is the path that is being added to the\n        phase, and pbxbuildfile must contain either a PBXFileReference directly\n        referencing that path, or it must contain a PBXVariantGroup that itself\n        contains a PBXFileReference referencing the path.\n\n        If path is not specified, either the PBXFileReference's path or the paths\n        of all children of the PBXVariantGroup are taken as being added to the\n        phase.\n\n        If the path is already present in the phase, raises an exception.\n\n        If the PBXFileReference or PBXVariantGroup referenced by pbxbuildfile\n        are already present in the phase, referenced by a different PBXBuildFile","sourceCodeStart":1867,"sourceCodeEnd":1903,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/gyp/xcodeproj_file.py#L1867-L1903","documentation":"Raised by a build phase's _AddPathToDict when a file path is added to a build phase (Sources, Resources, Frameworks, Copy Files) that already contains a PBXBuildFile for that exact path. Build phases track files by path to prevent the same file from appearing twice in the same phase, which would generate an invalid .pbxproj.","triggerScenarios":"AppendBuildFile or _AddBuildFileToDicts is called with a path string that already exists in self._files_by_path. This means the same source/resource/framework path is listed twice in a single build phase via the gyp configuration.","commonSituations":"A 'sources', 'mac_bundle_resources', 'link_settings'/'libraries', or similar list contains the same file path twice. Overlapping glob patterns. A file included via both direct listing and an include (.gypi) file.","solutions":["Deduplicate the file path in the target's relevant list (sources, resources, frameworks, etc.).","Audit any included .gypi files for files that also appear in the main .gyp.","Check glob patterns for overlap and use more specific patterns or exclude lists.","Re-run gyp after fixing to regenerate a clean .pbxproj."],"exampleFix":"# before\n'sources': ['src/a.c', 'src/b.c', 'src/a.c']\n# after\n'sources': ['src/a.c', 'src/b.c']","handlingStrategy":"validation","validationCode":"# Deduplicate file paths per build phase before generation\nphase_files = list(dict.fromkeys(phase_files))  # remove dupes preserving order","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remove duplicate entries from sources/resources/frameworks lists.","Use exclude/include patterns in gyp to prevent glob overlap."],"tags":["xcode","gyp","xcodeproj","build-phase","duplicate"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}