jdx/mise · error · RuntimeError
no Formula subclass found
Error message
no Formula subclass found
What it means
Raised by mise's tap_formula_metadata.rb driver after eval-ing the formula file: Formula.@subclass is nil, meaning the evaluated file never subclassed Formula, so no formula class was defined. The shim tracks Formula subclasses via an inherited hook, and this guard catches files that define no formula (helpers, empty files, or casks passed by mistake).
Solutions
- Verify MISE_BREW_SOURCE_PATH points at a .rb file containing a top-level `class X < Formula`
- Move the formula class definition out of any conditional wrapper
- Ensure the file is a formula, not a cask or helper module
- Check for earlier eval errors that prevented the class body from executing
Example fix
# before (file passed as formula) require_relative "../lib/foo_shared" # after class Foo < Formula desc "Foo" url "https://example.com/foo-1.0.tar.gz" sha256 "abc..." version "1.0" end
Defensive patterns
Strategy: validation
Validate before calling
raise "not a formula file" unless File.read(path).match?(/^\s*class\s+\w+\s*<\s*Formula/)
Type guard
def formula_file?(path) = !!(File.read(path) =~ /^\s*class\s+\w+\s*<\s*Formula/)
Try / catch
begin
metadata = parse_formula_metadata(formula_source)
rescue RuntimeError => e
raise unless e.message == "no Formula subclass found"
warn "#{formula_path} defines no Formula subclass; check MISE_BREW_SOURCE_PATH"
end Prevention
- Point MISE_BREW_SOURCE_PATH at the actual formula .rb file, not helpers or casks
- Keep `class X < Formula` at the top level, unconditioned
- Wire the formula and cask extraction scripts to distinct env vars to avoid cross-feeding paths
When it happens
Trigger: MISE_BREW_SOURCE_PATH points at a file without a `class Foo < Formula` definition; the formula class is defined inside a conditional that never ran; the file is a cask or shared helper instead of a formula; the class definition failed earlier leaving no subclass registered.
Common situations: Wrong env var wiring between formula/cask metadata scripts; tap reorganizations moving formulae; formulae wrapped in conditionals or defined via metaprogramming the shim's inherited hook misses.
Related errors
- could not infer formula version; add an explicit version…
- formula declares a DATA patch but has no __END__ section
- formula has no stable sha256
- formula has no stable URL
- inreplace in # made no substitutions — the formula may need…
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/d42ced4437138288.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/packages/brew/tap_formula_metadata.rb:236
end
# 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") },View on GitHub (pinned to 533346cc37)