nwjs/nw.js · critical · Exception
%d patches failed to apply. Your build will not be correct.
Error message
%d patches failed to apply. Your build will not be correct.
What it means
Raised by apply_patch_config() in tools/patcher.py after the loop over patches completes, when results['fail'] > 0. Each patch is applied via git_apply_patch_file; if any return 'fail', the build is considered incorrect because the Chromium source tree will be in a partially-patched state. The exception halts the build to prevent shipping a broken binary.
Source
Thrown at tools/patcher.py:95
if dopatch:
result = apply_patch_file(patch_file, patch['path']
if 'path' in patch else None)
results[result] += 1
if 'note' in patch:
write_note('NOTE', patch['note'])
else:
results['skip'] += 1
sys.stdout.write('\n%d patches total (%d applied, %d skipped, %d failed)\n' % \
(len(patches), results['apply'], results['skip'], results['fail']))
if results['fail'] > 0:
sys.stdout.write('\n')
write_note('ERROR',
'%d patches failed to apply. Your build will not be correct.' %
results['fail'])
raise Exception(
'%d patches failed to apply. Your build will not be correct.' %
results['fail'])
# Parse command-line options.
disc = """
This utility applies patch files.
"""
parser = OptionParser(description=disc)
parser.add_option(
'--patch-file', dest='patchfile', metavar='FILE', help='patch source file')
parser.add_option(
'--patch-dir',
dest='patchdir',
metavar='DIR',
help='patch target directory')
# NWJS: Path of config file has been hard-coded in this script, so this optionView on GitHub (pinned to e15da848e9)
Solutions
- Inspect the per-patch 'This patch failed to apply' NOTE output above the summary to identify which patch(es) failed.
- Rebase the offending .patch file against the current Chromium source: regenerate with git diff or manually fix context lines.
- Reset the source tree to a clean state (git checkout . in the Chromium src dir) and re-run patcher to rule out a half-patched tree.
- Verify the Chromium revision matches what the NW.js patches target (check DEPS / the pinned commit).
Defensive patterns
Strategy: try-catch
Validate before calling
import subprocess
def patch_applies_cleanly(patch_path, src_dir):
result = subprocess.run(['git', 'apply', '--check', patch_path], cwd=src_dir)
return result.returncode == 0 Try / catch
try:
apply_patch_config()
except Exception as e:
if 'patches failed to apply' in str(e):
# reset tree and rebase patches against current Chromium rev
subprocess.run(['git', 'checkout', '.'], cwd=src_dir)
raise SystemExit('Rebase failed patches against the current Chromium revision, then rebuild.')
raise Prevention
- Keep the Chromium revision in sync with what the NW.js patches target (check DEPS).
- Reset the source tree to a clean state before re-running patcher to avoid half-patched conflicts.
- Re-generate stale .patch files with git diff when rebasing onto a new Chromium version.
- Watch line-ending settings (core.autocrlf) that can break git apply.
When it happens
Trigger: A patch in patch.cfg no longer applies cleanly against the checked-out Chromium revision (context mismatch, already-applied hunk, conflicting upstream change); a patch file referenced by patch.cfg is missing from patch/patches/; line-ending or whitespace drift causing git apply to reject a hunk.
Common situations: Upgrading the Chromium revision without rebasing the NW.js patches; switching OS line endings (CRLF/LF) that confuse git apply; partial previous run leaving the tree half-patched so re-application conflicts; stale patch files after a branch switch.
Related errors
- Patch config file %s does not exist.
- Invaild parameter, need Shortcut object.
- It's forbidden to instantialize a Base class.
- Type of '{type}' is not supported
- Only support getting plain text from Clipboard
AI-assisted analysis of nwjs/nw.js@e15da848e9 (2026-08-13).
Data as JSON: /api/errors/2d88ce50717d5f86.
Report an issue: GitHub.