jdx/mise · error · RuntimeError
formula declares a DATA patch but has no __END__ section
Error message
formula declares a DATA patch but has no __END__ section
What it means
The brew shim's Patch#apply! supports DATA-style patches whose content lives after `__END__` in the formula file. It raises when a patch was declared with `:DATA` (setting @data = true) but the formula file contains no `__END__` marker, so split returns nil content.
Solutions
- Append a `__END__` line followed by the patch content to the formula file.
- Remove the `patch :DATA` declaration if the patch is no longer needed.
- Convert to a URL-based patch (`patch do url ... end`) instead of DATA.
- Check for invisible characters/casing that break the /^__END__$/ match.
Example fix
# before patch :DATA # (file ends without __END__) # after patch :DATA __END__ --- a/src/config.c +++ b/src/config.c @@ -1,3 +1,3 @@ ...
Defensive patterns
Strategy: validation
Validate before calling
text = formula_file.read raise "DATA patch needs __END__" if text[/^__END__$/].nil? && text.match?(/^\s*patch\s+:DATA/)
Try / catch
begin
patch.apply!
rescue RuntimeError => e
raise unless e.message.include?("__END__ section")
# add __END__ data or drop the patch
end Prevention
- When adding `patch :DATA`, immediately append __END__ + diff
- Grep formulas for `patch :DATA` and verify each has __END__
- Prefer URL patches over DATA for tooling-friendliness
When it happens
Trigger: A formula adds `patch :DATA` without appending a `__END__` section holding the unified diff; the `__END__` line was removed or misspelled (e.g. whitespace/casing preventing the /^__END__$/ match).
Common situations: Hand-edited formulas where the diff was deleted but the `patch :DATA` declaration remained; ported formulas from Homebrew where the data section was stripped by tooling.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- inreplace in # made no substitutions — the formula may need…
- patch failed: #
- cannot install # : does not exist
- command failed: #
- completion generation failed: #
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/eaa12c6b8385a1ad.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/packages/brew/shim.rb:461
def url(url = nil, **)
@url = url unless url.nil?
@url
end
def sha256(sha = nil)
@sha256 = sha unless sha.nil?
@sha256
end
def data!
@data = true
end
def apply!
if @data
content = @formula_file.read.split(/^__END__$/, 2)[1]
raise "formula declares a DATA patch but has no __END__ section" if content.nil?
apply_content(content.sub(/\A\n/, ""))
elsif @url
file = MiseDownload.fetch(@url, @sha256, "patch")
apply_content(file.read)
end
end
private
def apply_content(content)
ohai "Applying patch (-p#{@strip})"
Open3.popen2e("patch", "-g", "0", "-f", "-p#{@strip}") do |stdin, out, thread|
stdin.write(content)
stdin.close
output = out.read
raise "patch failed:\n#{output}" unless thread.value.success?
$stdout.puts output
endView on GitHub (pinned to 533346cc37)