{"record":{"id":"f0c1f4a076568471","repo":"nodejs/node","slug":"s-error-no-build-file","errorCode":null,"errorMessage":"%s: error: no build_file","messagePattern":"(.+?): error: no build_file","errorType":"exception","errorClass":"GypError","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/gyp/__init__.py","lineNumber":567,"sourceCode":"\n    for mode in options.debug:\n        gyp.debug[mode] = 1\n\n    # Do an extra check to avoid work when we're not debugging.\n    if DEBUG_GENERAL in gyp.debug:\n        DebugOutput(DEBUG_GENERAL, \"running with these options:\")\n        for option, value in sorted(options.__dict__.items()):\n            if option[0] == \"_\":\n                continue\n            if isinstance(value, str):\n                DebugOutput(DEBUG_GENERAL, \"  %s: '%s'\", option, value)\n            else:\n                DebugOutput(DEBUG_GENERAL, \"  %s: %s\", option, value)\n\n    if not build_files:\n        build_files = FindBuildFiles()\n    if not build_files:\n        raise GypError((usage + \"\\n\\n%s: error: no build_file\") % (my_name, my_name))\n\n    # TODO(mark): Chromium-specific hack!\n    # For Chromium, the gyp \"depth\" variable should always be a relative path\n    # to Chromium's top-level \"src\" directory.  If no depth variable was set\n    # on the command line, try to find a \"src\" directory by looking at the\n    # absolute path to each build file's directory.  The first \"src\" component\n    # found will be treated as though it were the path used for --depth.\n    if not options.depth:\n        for build_file in build_files:\n            build_file_dir = os.path.abspath(os.path.dirname(build_file))\n            build_file_dir_components = build_file_dir.split(os.path.sep)\n            components_len = len(build_file_dir_components)\n            for index in range(components_len - 1, -1, -1):\n                if build_file_dir_components[index] == \"src\":\n                    options.depth = os.path.sep.join(build_file_dir_components)\n                    break\n                del build_file_dir_components[index]\n","sourceCodeStart":549,"sourceCodeEnd":585,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/gyp/__init__.py#L549-L585","documentation":"gyp main raises GypError('%s: error: no build_file') after both the command line and FindBuildFiles() come up empty. Gyp needs at least one .gyp/.gypi build file as input to generate project files; with none supplied and none auto-discovered, it cannot proceed. The message is formatted with the program name (my_name) so the usage string reads naturally.","triggerScenarios":"Running `gyp` with no positional arguments in a directory with no *.gyp files; passing only flags (-D, --depth) but no build file; FindBuildFiles globs a pattern that matches nothing.","commonSituations":"Wrong cwd (running gyp from repo root when the .gyp lives in a subdirectory); typo'd build file name that the shell swallowed; CI step that forgot to cd into the project dir.","solutions":["Pass the path to a .gyp file explicitly: `gyp path/to/project.gyp`.","Run gyp from the directory containing the .gyp file so FindBuildFiles can auto-discover it.","Check the file extension is .gyp/.gypi and not mangled by VFS case sensitivity."],"exampleFix":"# before\npython gyp\n\n# after\npython gyp build/all.gyp","handlingStrategy":"validation","validationCode":"import os, sys\nargs = sys.argv[1:]\nbuild_files = [a for a in args if a.endswith(('.gyp',))]\nif not build_files and not glob.glob('*.gyp'):\n    raise SystemExit('No .gyp build file found. Pass one explicitly, e.g. gyp project.gyp')","typeGuard":"def has_build_file(args) -> bool:\n    import os\n    return any(a.endswith('.gyp') for a in args) or bool(glob.glob('*.gyp'))","tryCatchPattern":"try:\n    gyp_main(args)\nexcept GypError as e:\n    if 'no build_file' in str(e):\n        args.append('build/all.gyp')  # then retry with an explicit file\n        raise","preventionTips":["Always pass the .gyp file path explicitly on the gyp command line.","Run gyp from the directory that actually contains the .gyp file.","In wrappers, assert a build file exists before delegating to gyp."],"tags":["gyp","cli","usage","build-file","config"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}