jdx/mise · error · RuntimeError
formula has no stable sha256
Error message
formula has no stable sha256
What it means
Raised by mise's tap_formula_metadata.rb when the formula class exists and has a stable source_url but no stable source sha256. The sha256 is required so mise can verify the downloaded source archive; building without it would skip integrity checking, so the shim refuses to emit metadata instead.
Solutions
- Add a correct `sha256` stanza (hash of the source archive at url) to the formula
- Extend the shim to read sha256 from the block the formula uses
- Pin the formula to a revision that declares a stable sha256
- Use a formula variant that provides checksums instead of sha256 :no_check
Example fix
# before (formula) class Foo < Formula version "1.0" url "https://example.com/foo-1.0.tar.gz" end # after class Foo < Formula version "1.0" url "https://example.com/foo-1.0.tar.gz" sha256 "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" end
Defensive patterns
Strategy: validation
Validate before calling
raise "formula has no sha256" unless formula_source.match?(/^\s*sha256\s+["'][0-9a-f]{64}["']/) Type guard
def has_stable_sha256?(klass) = !klass.source_sha256.to_s.empty?
Try / catch
begin metadata = parse_formula_metadata(formula_source) rescue RuntimeError => e raise unless e.message == "formula has no stable sha256" warn "formula lacks a sha256; cannot verify source" end
Prevention
- Always compute and declare sha256 for the source archive in hand-written formulae
- Avoid sha256 :no_check when integrity matters
- Resolve sha256 declared in conditional blocks for the target platform before extraction
When it happens
Trigger: Formula omits the sha256 stanza; sha256 is set only for a spec the shim is not reading (e.g. inside on_macos/on_linux blocks or a non-stable spec); the formula relies on Homebrew-only mechanisms like bottle-only distribution; sha256 :no_check usage the shim does not accept.
Common situations: Hand-written third-party formulae missing checksums; formulae updated upstream to conditional sha256 blocks; conversion of Homebrew JSON metadata that dropped the checksum.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/e312766942bfc42b.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/packages/brew/tap_formula_metadata.rb:238
# Match the formulae.brew.sh JSON: symbol reasons serialize as ":name",
# string reasons as-is.
def keg_only_reason_metadata(klass)
reason = klass.keg_only_reason_value
return nil if reason.nil?
{ "reason" => reason.is_a?(Symbol) ? reason.inspect : reason.to_s }
end
def inferred_version(url)
basename = File.basename(url.to_s).sub(/\.(tar\.(gz|xz|bz2|zst)|tgz|txz|zip|gz)\z/i, "")
match = basename.match(/(?:^|[-_v])([0-9]+(?:\.[0-9A-Za-z]+)+(?:[-_.][0-9A-Za-z]+)*)/)
match && match[1]
end
eval(STDIN.read.force_encoding("UTF-8"), TOPLEVEL_BINDING, FORMULA_FILE, 1)
klass = Formula.instance_variable_get(:@subclass)
raise "no Formula subclass found" unless klass
raise "formula has no stable URL" if klass.source_url.to_s.empty?
raise "formula has no stable sha256" if klass.source_sha256.to_s.empty?
version = (klass.explicit_version || inferred_version(klass.source_url)).to_s
raise "could not infer formula version; add an explicit version declaration" if version.to_s.empty?
metadata = {
"name" => FORMULA_NAME,
"tap" => ENV.fetch("MISE_BREW_TAP"),
"versions" => { "stable" => version },
"revision" => klass.revision_value || 0,
"keg_only" => klass.keg_only_value || false,
"keg_only_reason" => keg_only_reason_metadata(klass),
"dependencies" => klass.runtime_dependencies || [],
"build_dependencies" => klass.build_dependencies || [],
"bottle" => {},
"urls" => { "stable" => { "url" => klass.source_url, "checksum" => klass.source_sha256 } },
"ruby_source_path" => ENV.fetch("MISE_BREW_SOURCE_PATH"),
"ruby_source_checksum" => { "sha256" => ENV.fetch("MISE_BREW_SOURCE_CHECKSUM") },
"tap_git_head" => ENV.fetch("MISE_BREW_TAP_COMMIT")
}View on GitHub (pinned to 533346cc37)