jdx/mise · error · RuntimeError

formula has no stable URL

Error message

formula has no stable URL

What it means

Raised by mise's tap_formula_metadata.rb after a Formula subclass was found but its stable source_url is empty. mise builds third-party formulae from source and requires the formula's stable (non-legacy) url to know where to download the source; a formula without one cannot be processed. This is the first of three completeness checks on the class after the subclass guard.

Solutions

  1. Add a stable `url` stanza to the formula
  2. Extend the shim to resolve the URL construct the formula uses (e.g. conditional on_macos/on_linux urls)
  3. Pin the formula to a revision with a stable url
  4. Choose a different formula/package that provides a stable source URL

Example fix

# before (formula)
class Foo < Formula
  desc "Foo"
  version "1.0"
end
# after
class Foo < Formula
  desc "Foo"
  version "1.0"
  url "https://example.com/foo-1.0.tar.gz"
  sha256 "abc..."
end
Defensive patterns

Strategy: validation

Validate before calling

raise "formula has no url" unless formula_source.match?(/^\s*url\s+["']https?:/)

Type guard

def has_stable_url?(klass) = !klass.source_url.to_s.empty?

Try / catch

begin
  metadata = parse_formula_metadata(formula_source)
rescue RuntimeError => e
  raise unless e.message == "formula has no stable URL"
  warn "formula lacks a stable url; cannot build from source"
end

Prevention

When it happens

Trigger: Formula defines no url stanza; url is only set in a deprecated/bottle or nested block; the stable spec is empty because the formula uses only devel/head specs; url is assigned via metaprogramming the shim does not execute.

Common situations: Head-only or bottle-only formulae; formulae defining url inside on_macos/on_linux conditional blocks; third-party formulae missing required stanzas.

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/c57c130c32a8b6c0. Report an issue: GitHub.

Appendix: source

Thrown at src/system/packages/brew/tap_formula_metadata.rb:237

# 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)