{"record":{"id":"80d228191db4dcac","repo":"jdx/mise","slug":"cask-has-no-version","errorCode":null,"errorMessage":"cask has no version","messagePattern":"cask has no version","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/tap_cask_metadata.rb","lineNumber":293,"sourceCode":"    when :or_older then host <= target || host.same_release?(target)\n    when :or_newer then host >= target\n    else host.same_release?(target)\n    end\n  end\n  private :macos_condition_matches?\n\n  def name(*) = nil\n  def desc(*) = nil\n  def homepage(*) = nil\n  def livecheck(*) = nil\n  def caveats(*) = nil\n  def container(*) = nil\n  def deprecate!(**) = nil\n  def disable!(**) = nil\n  def no_autobump!(*) = nil\n\n  def to_h\n    raise \"cask has no version\" if @version.nil?\n    raise \"cask has no URL\" if @url.to_s.empty?\n    {\n      \"token\" => @token,\n      \"version\" => @version.to_s,\n      \"auto_updates\" => @auto_updates,\n      \"url\" => @url,\n      \"sha256\" => @sha256,\n      \"artifacts\" => @artifacts,\n      \"depends_on\" => {\n        \"formula\" => @formula_dependencies,\n        \"cask\" => @cask_dependencies\n      },\n      \"conflicts_with\" => { \"cask\" => @conflicting_casks },\n      \"ruby_source_path\" => ENV.fetch(\"MISE_BREW_SOURCE_PATH\"),\n      \"ruby_source_checksum\" => { \"sha256\" => ENV.fetch(\"MISE_BREW_SOURCE_CHECKSUM\") },\n      \"tap_git_head\" => ENV.fetch(\"MISE_BREW_TAP_COMMIT\")\n    }\n  end","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/brew/tap_cask_metadata.rb#L275-L311","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Fix the cask parsing shim to capture the version from the construct the cask uses (e.g. handle nested/conditional stanzas)","Set an explicit version in the cask file","Update mise to a version with broader cask DSL support","Pin the cask to a revision with a plain `version` stanza"],"exampleFix":"# before (cask)\ncask \"foo\" do\n  version :latest\n  url \"https://example.com/foo.dmg\"\nend\n# after (cask)\ncask \"foo\" do\n  version \"1.2.3\"\n  url \"https://example.com/foo-1.2.3.dmg\"\n  sha256 \"abc123...\"\nend","handlingStrategy":"validation","validationCode":"raise \"cask has no version stanza\" unless cask_source.match?(/^\\s*version\\s+[\"':]/)","typeGuard":"def has_version?(metadata) = !metadata.version.nil?","tryCatchPattern":"begin\n  metadata = parse_cask_metadata(cask_source)\nrescue RuntimeError => e\n  raise unless e.message == \"cask has no version\"\n  warn \"cask #{token} lacks a version; skipping\"\nend","preventionTips":["Only use casks that declare a concrete version string","Avoid version :latest casks for source-build workflows","Keep the shim's version parsing in sync with conditional on_macos/on_arm stanzas you rely on"],"tags":["ruby","cask","metadata","missing-field"],"backgroundTag":"empty-required-field","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"}