jdx/mise · error · RuntimeError
expected cask # , got #
Error message
expected cask #{expected}, got #{metadata.token} What it means
Raised by mise's tap_cask_metadata.rb driver after evaluating the cask file: the cask block that was found declares a different token than the MISE_BREW_TOKEN env var the driver expects. mise extracts metadata for one specific cask and uses this guard to catch reading the wrong file or a cask whose token header does not match the requested tool.
Solutions
- Point MISE_BREW_SOURCE_PATH at the cask file whose cask token equals MISE_BREW_TOKEN
- Update the tap checkout so token and filename agree
- Update mise or its pinned tap ref to pick up upstream cask renames
- Fix the cask file so its header token matches its filename
Example fix
# before (cask file foo.rb) cask "foo-cli" do version "1.0" end # after cask "foo" do version "1.0" end
Defensive patterns
Strategy: validation
Validate before calling
header = File.read(path)[/^\s*cask\s+["']([^"']+)["']/, 1]
raise "token mismatch: #{header.inspect} != #{ENV.fetch('MISE_BREW_TOKEN')}" unless header == ENV.fetch("MISE_BREW_TOKEN") Type guard
def token_matches?(path, expected) = File.read(path)[/^\s*cask\s+["']([^"']+)["']/, 1] == expected
Try / catch
begin
metadata = parse_cask_metadata(cask_source)
rescue RuntimeError => e
raise unless e.message.start_with?("expected cask ")
warn "wrong cask file for token; re-resolving source path"
end Prevention
- Derive MISE_BREW_SOURCE_PATH from the token (tap path + "#{token}.rb") instead of hardcoding
- Re-sync the tap after upstream cask renames
- Verify the cask header token equals its filename before extraction
When it happens
Trigger: MISE_BREW_SOURCE_PATH points at a different cask file than MISE_BREW_TOKEN names; the cask's token was renamed upstream while mise still requests the old token; a header_token mismatch, e.g. cask file "google-chrome.rb" defining `cask "google-chrome-dev"`; copy/paste of one cask's body into another file.
Common situations: Upstream cask renames between header token and filename convention; stale tap checkout; mise's brew resolver and the tap checkout out of sync about the token.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- cask has no URL
- cask has no version
- formula has no stable URL
- no cask block found
- unsupported cask flight step DSL `#
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/dda37ddf5a1500db.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/packages/brew/tap_cask_metadata.rb:343
end
def add_artifact(kind, source, target)
value = [source.to_s]
value << { "target" => target.to_s } unless target.nil?
@artifacts << { kind => value }
end
end
def cask(token, &block)
$mise_cask_metadata = CaskMetadata.new(token)
$mise_cask_metadata.instance_eval(&block)
end
eval(STDIN.read.force_encoding("UTF-8"), TOPLEVEL_BINDING, CASK_FILE, 1)
metadata = $mise_cask_metadata
raise "no cask block found" if metadata.nil?
expected = ENV.fetch("MISE_BREW_TOKEN")
raise "expected cask #{expected}, got #{metadata.token}" if metadata.token != expected
puts JSON.generate(metadata.to_h)
View on GitHub (pinned to 533346cc37)