{"record":{"id":"38df5942ff5631b0","repo":"nodejs/node","slug":"could-not-find-target-s","errorCode":null,"errorMessage":"Could not find target %s","messagePattern":"Could not find target (.+?)","errorType":"exception","errorClass":"GypError","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/gyp/input.py","lineNumber":2860,"sourceCode":"def TurnIntIntoStrInList(the_list):\n    \"\"\"Given list the_list, recursively converts all integers into strings.\"\"\"\n    for index, item in enumerate(the_list):\n        if isinstance(item, int):\n            the_list[index] = str(item)\n        elif isinstance(item, dict):\n            TurnIntIntoStrInDict(item)\n        elif isinstance(item, list):\n            TurnIntIntoStrInList(item)\n\n\ndef PruneUnwantedTargets(targets, flat_list, dependency_nodes, root_targets, data):\n    \"\"\"Return only the targets that are deep dependencies of |root_targets|.\"\"\"\n    qualified_root_targets = []\n    for target in root_targets:\n        target = target.strip()\n        qualified_targets = gyp.common.FindQualifiedTargets(target, flat_list)\n        if not qualified_targets:\n            raise GypError(\"Could not find target %s\" % target)\n        qualified_root_targets.extend(qualified_targets)\n\n    wanted_targets = {}\n    for target in qualified_root_targets:\n        wanted_targets[target] = targets[target]\n        for dependency in dependency_nodes[target].DeepDependencies():\n            wanted_targets[dependency] = targets[dependency]\n\n    wanted_flat_list = [t for t in flat_list if t in wanted_targets]\n\n    # Prune unwanted targets from each build_file's data dict.\n    for build_file in data[\"target_build_files\"]:\n        if \"targets\" not in data[build_file]:\n            continue\n        new_targets = []\n        for target in data[build_file][\"targets\"]:\n            qualified_name = gyp.common.QualifiedTarget(\n                build_file, target[\"target_name\"], target[\"toolset\"]","sourceCodeStart":2842,"sourceCodeEnd":2878,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/gyp/input.py#L2842-L2878","documentation":"PruneUnwantedTargets is invoked when gyp is told to build only a subset of targets (e.g. via the --build/--depth root target list). For each requested target string it calls gyp.common.FindQualifiedTargets against the full flat target list; if nothing matches the (possibly qualified) name, gyp cannot proceed and raises GypError.","triggerScenarios":"A target specifier passed to gyp as a root target does not match any entry in the flattened target list, after stripping and qualified-name resolution.","commonSituations":"Typing a target name that does not exist or was renamed; using a path qualifier (foo.gyp:bar) that points to a different file or target; referencing a target from a .gyp file that is not part of the build; case mismatch in the target name.","solutions":["List available targets (gyp --dump-input or inspect the relevant .gyp files) and confirm the exact qualified name 'path/file.gyp:target'.","Correct the spelling/path/case of the requested target to match exactly.","If the target was removed or renamed, update the build invocation to the new name.","Ensure the .gyp file containing the target is included in the build (depth/source arguments)."],"exampleFix":"// before\n$ gyp --depth=. build/all.gyp build/missing.gyp:ghost_target\n// after\n$ gyp --depth=. build/all.gyp build/real.gyp:real_target","handlingStrategy":"validation","validationCode":"# Validate requested root targets against the known flat list before pruning.\nknown = set(flat_list)\nfor t in root_targets:\n    if not gyp.common.FindQualifiedTargets(t.strip(), flat_list):\n        raise ValueError(f'requested target not found: {t}')","typeGuard":"def all_root_targets_resolvable(root_targets, flat_list) -> bool:\n    return all(\n        gyp.common.FindQualifiedTargets(t.strip(), flat_list)\n        for t in root_targets\n    )","tryCatchPattern":null,"preventionTips":["Quote target names exactly as defined (case-sensitive).","When renaming/removing a target, update all build scripts and CI configs that reference it.","Prefer fully-qualified 'path/file.gyp:target' forms to avoid ambiguity."],"tags":["gyp","targets","not-found","prune"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}