{"record":{"id":"eaa12c6b8385a1ad","repo":"jdx/mise","slug":"formula-declares-a-data-patch-but-has-no-end-s","errorCode":null,"errorMessage":"formula declares a DATA patch but has no __END__ section","messagePattern":"formula declares a DATA patch but has no __END__ section","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/shim.rb","lineNumber":461,"sourceCode":"\n  def url(url = nil, **)\n    @url = url unless url.nil?\n    @url\n  end\n\n  def sha256(sha = nil)\n    @sha256 = sha unless sha.nil?\n    @sha256\n  end\n\n  def data!\n    @data = true\n  end\n\n  def apply!\n    if @data\n      content = @formula_file.read.split(/^__END__$/, 2)[1]\n      raise \"formula declares a DATA patch but has no __END__ section\" if content.nil?\n      apply_content(content.sub(/\\A\\n/, \"\"))\n    elsif @url\n      file = MiseDownload.fetch(@url, @sha256, \"patch\")\n      apply_content(file.read)\n    end\n  end\n\n  private\n\n  def apply_content(content)\n    ohai \"Applying patch (-p#{@strip})\"\n    Open3.popen2e(\"patch\", \"-g\", \"0\", \"-f\", \"-p#{@strip}\") do |stdin, out, thread|\n      stdin.write(content)\n      stdin.close\n      output = out.read\n      raise \"patch failed:\\n#{output}\" unless thread.value.success?\n      $stdout.puts output\n    end","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/packages/brew/shim.rb#L443-L479","documentation":"The shim's Patch apply! supports DATA patches, which store the patch content after the formula file's __END__ marker. It raises when a patch was declared as DATA (@data = true) but the formula file contains no __END__ section, so there is no patch content to extract.","triggerScenarios":"A formula declares `patch :data` but the file lacks `__END__` followed by the unified diff; formula was truncated when copied; patch DSL mismatch where content was expected inline after __END__.","commonSituations":"Hand-copied formulas missing the trailing patch text; editors or linters stripping content after __END__; formula ports from Homebrew where the DATA patch section was dropped.","solutions":["Append __END__ to the formula file followed by the patch content","Move the patch to a url-based patch (`patch do url ... end`) if inline data isn't wanted","Check the formula file wasn't truncated during copy/download"],"exampleFix":"# before\ndef patch\n  patch :data\nend\n# (file ends here)\n# after\ndef patch\n  patch :data\nend\n__END__\n--- a/src/config.c\n+++ b/src/config.c\n@@ -1,3 +1,3 @@\n-OLD\n+NEW","handlingStrategy":"validation","validationCode":"raise \"DATA patch without __END__\" if patch_data && !formula_file.read.include?(\"__END__\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify __END__ + patch body survive any formula copy/transform","Prefer url patches for long diffs to avoid file-truncation issues","Lint formulas that use patch :data for the __END__ marker"],"tags":["ruby","patch","formula"],"backgroundTag":"empty-required-field","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}