{"record":{"id":"d42ced4437138288","repo":"jdx/mise","slug":"no-formula-subclass-found","errorCode":null,"errorMessage":"no Formula subclass found","messagePattern":"no Formula subclass found","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/tap_formula_metadata.rb","lineNumber":236,"sourceCode":"end\n\n# Match the formulae.brew.sh JSON: symbol reasons serialize as \":name\",\n# string reasons as-is.\ndef keg_only_reason_metadata(klass)\n  reason = klass.keg_only_reason_value\n  return nil if reason.nil?\n  { \"reason\" => reason.is_a?(Symbol) ? reason.inspect : reason.to_s }\nend\n\ndef inferred_version(url)\n  basename = File.basename(url.to_s).sub(/\\.(tar\\.(gz|xz|bz2|zst)|tgz|txz|zip|gz)\\z/i, \"\")\n  match = basename.match(/(?:^|[-_v])([0-9]+(?:\\.[0-9A-Za-z]+)+(?:[-_.][0-9A-Za-z]+)*)/)\n  match && match[1]\nend\n\neval(STDIN.read.force_encoding(\"UTF-8\"), TOPLEVEL_BINDING, FORMULA_FILE, 1)\nklass = Formula.instance_variable_get(:@subclass)\nraise \"no Formula subclass found\" unless klass\nraise \"formula has no stable URL\" if klass.source_url.to_s.empty?\nraise \"formula has no stable sha256\" if klass.source_sha256.to_s.empty?\nversion = (klass.explicit_version || inferred_version(klass.source_url)).to_s\nraise \"could not infer formula version; add an explicit version declaration\" if version.to_s.empty?\n\nmetadata = {\n  \"name\" => FORMULA_NAME,\n  \"tap\" => ENV.fetch(\"MISE_BREW_TAP\"),\n  \"versions\" => { \"stable\" => version },\n  \"revision\" => klass.revision_value || 0,\n  \"keg_only\" => klass.keg_only_value || false,\n  \"keg_only_reason\" => keg_only_reason_metadata(klass),\n  \"dependencies\" => klass.runtime_dependencies || [],\n  \"build_dependencies\" => klass.build_dependencies || [],\n  \"bottle\" => {},\n  \"urls\" => { \"stable\" => { \"url\" => klass.source_url, \"checksum\" => klass.source_sha256 } },\n  \"ruby_source_path\" => ENV.fetch(\"MISE_BREW_SOURCE_PATH\"),\n  \"ruby_source_checksum\" => { \"sha256\" => ENV.fetch(\"MISE_BREW_SOURCE_CHECKSUM\") },","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/brew/tap_formula_metadata.rb#L218-L254","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before (file passed as formula)\nrequire_relative \"../lib/foo_shared\"\n# after\nclass Foo < Formula\n  desc \"Foo\"\n  url \"https://example.com/foo-1.0.tar.gz\"\n  sha256 \"abc...\"\n  version \"1.0\"\nend","handlingStrategy":"validation","validationCode":"raise \"not a formula file\" unless File.read(path).match?(/^\\s*class\\s+\\w+\\s*<\\s*Formula/)","typeGuard":"def formula_file?(path) = !!(File.read(path) =~ /^\\s*class\\s+\\w+\\s*<\\s*Formula/)","tryCatchPattern":"begin\n  metadata = parse_formula_metadata(formula_source)\nrescue RuntimeError => e\n  raise unless e.message == \"no Formula subclass found\"\n  warn \"#{formula_path} defines no Formula subclass; check MISE_BREW_SOURCE_PATH\"\nend","preventionTips":["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"],"tags":["ruby","formula","parse-failure","missing-class"],"backgroundTag":"class-not-found","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}