jdx/mise · error · RuntimeError
no cask block found
Error message
no cask block found
What it means
Raised at the top level of mise's tap_cask_metadata.rb evaluation script after it evals the cask file from stdin: if the global $mise_cask_metadata is still nil, the cask never registered itself, meaning the cask file contained no `cask ... do ... end` block the shim recognized (the block hook creates the CaskMetadata instance). This catches empty, malformed, or non-cask Ruby files passed as CASK_FILE.
Solutions
- Verify MISE_BREW_SOURCE_PATH points at the actual cask .rb file containing a top-level cask block
- Fix the cask file so its cask block is unconditional
- Ensure MISE_BREW_OS matches the cask's platform guards
- Inspect the cask for wrappers (conditionals, begin/rescue) that prevent the cask method from being invoked
Example fix
# before (cask) cask "foo" do version "1.0" end if OS.mac? # after (cask) cask "foo" do version "1.0" end
Defensive patterns
Strategy: validation
Validate before calling
raise "not a cask file" unless File.read(path).match?(/^\s*cask\s+["'][^"']+["']\s+do/)
Type guard
def cask_file?(path) = !!(File.read(path) =~ /^\s*cask\s+["'][^"']+["']\s+do/)
Try / catch
begin
metadata = parse_cask_metadata(cask_source)
rescue RuntimeError => e
raise unless e.message == "no cask block found"
warn "#{cask_path} contains no cask block; check MISE_BREW_SOURCE_PATH"
end Prevention
- Always set MISE_BREW_SOURCE_PATH to the exact cask .rb file
- Validate the file's first non-comment line before running the extraction script
- Keep platform guards in casks unconditional or match MISE_BREW_OS to them
When it happens
Trigger: MISE_BREW_SOURCE_PATH points at a file with no cask block; the cask file is empty or its `cask` block is wrapped in a conditional that never ran; the file is actually a formula, not a cask; an earlier DSL error path left the metadata global unset.
Common situations: Misconfigured env var pointing at the wrong source file; tap layout changes so the shim reads a helper file instead of the cask; casks guarded by `if OS.mac?` while the shim runs with the other OS value in MISE_BREW_OS.
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
- cask has no URL
- cask has no version
- expected cask # , got #
- no Formula subclass found
- unsupported cask flight step DSL `#
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/a1e7cd11ceec6020.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/packages/brew/tap_cask_metadata.rb:341
collector.instance_eval(&block)
@artifacts << { kind => [{ "steps" => collector.steps }] }
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)