jdx/mise · error · RuntimeError

cask has no version

Error message

cask has no version

What it means

Raised by CaskMetadata#to_h in mise's tap_cask_metadata.rb shim when serializing parsed cask metadata if the version stanza was never seen. The shim extracts only the fields mise needs (token, version, url, sha256), and a cask without a resolvable version cannot be turned into valid metadata for mise's brew backend. It fires before the URL check, so it is the first completeness validation on the collected metadata.

Solutions

  1. Fix the cask parsing shim to capture the version from the construct the cask uses (e.g. handle nested/conditional stanzas)
  2. Set an explicit version in the cask file
  3. Update mise to a version with broader cask DSL support
  4. Pin the cask to a revision with a plain `version` stanza

Example fix

# before (cask)
cask "foo" do
  version :latest
  url "https://example.com/foo.dmg"
end
# after (cask)
cask "foo" do
  version "1.2.3"
  url "https://example.com/foo-1.2.3.dmg"
  sha256 "abc123..."
end
Defensive patterns

Strategy: validation

Validate before calling

raise "cask has no version stanza" unless cask_source.match?(/^\s*version\s+["':]/)

Type guard

def has_version?(metadata) = !metadata.version.nil?

Try / catch

begin
  metadata = parse_cask_metadata(cask_source)
rescue RuntimeError => e
  raise unless e.message == "cask has no version"
  warn "cask #{token} lacks a version; skipping"
end

Prevention

When it happens

Trigger: The cask file has no version stanza; version is defined conditionally (e.g. inside a block like on_macos/on_arm that did not execute) or behind a livecheck/auto_updates pattern the shim does not evaluate; the version DSL call failed silently through an unsupported-stanza path.

Common situations: Casks that compute version dynamically or via nested stanzas; upstream cask rewrites where version moved into a shim-unsupported construct; tap casks relying on Homebrew-only helpers mise's minimal DSL lacks.

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

Appendix: source

Thrown at src/system/packages/brew/tap_cask_metadata.rb:293

    when :or_older then host <= target || host.same_release?(target)
    when :or_newer then host >= target
    else host.same_release?(target)
    end
  end
  private :macos_condition_matches?

  def name(*) = nil
  def desc(*) = nil
  def homepage(*) = nil
  def livecheck(*) = nil
  def caveats(*) = nil
  def container(*) = nil
  def deprecate!(**) = nil
  def disable!(**) = nil
  def no_autobump!(*) = nil

  def to_h
    raise "cask has no version" if @version.nil?
    raise "cask has no URL" if @url.to_s.empty?
    {
      "token" => @token,
      "version" => @version.to_s,
      "auto_updates" => @auto_updates,
      "url" => @url,
      "sha256" => @sha256,
      "artifacts" => @artifacts,
      "depends_on" => {
        "formula" => @formula_dependencies,
        "cask" => @cask_dependencies
      },
      "conflicts_with" => { "cask" => @conflicting_casks },
      "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")
    }
  end

View on GitHub (pinned to 533346cc37)