jdx/mise · error · RuntimeError
no cask block found
Error message
no cask block found
What it means
At the bottom of the tap cask metadata eval script, the parsed cask metadata is held in `$mise_cask_metadata`, which is only assigned when a `cask ... do ... end` block actually executes. If the evaluated cask file contained no such block (so the global stays nil), the script raises 'no cask block found' before serializing JSON. It's a sanity gate ensuring a cask was actually parsed.
Source
Thrown at src/system/packages/brew/tap_cask_metadata.rb:292
def respond_to_missing?(*) = true
private
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 afd2eddd3a)
Solutions
- Ensure the file evaluated is a cask and begins with a top-level `cask ... do` block
- Verify the path/env (CASK_FILE / MISE_BREW_TOKEN) selects the intended cask file in the tap
- Re-fetch the tap if the cask file is empty or truncated
- Check the cask block isn't guarded by a conditional that prevents it from executing at top level
Example fix
# before (evaluated file) # empty or formula content # after cask 'mytool' do version '1.2.3' url 'https://example.com/mytool-1.2.3.zip' sha256 :no_check end
Defensive patterns
Strategy: validation
Validate before calling
src = File.read(cask_path) raise 'not a cask file' unless src.match?(/^\s*cask\s+['\"]/)
Try / catch
begin run_cask_metadata_extraction(cask_path) rescue RuntimeError => e raise unless e.message == 'no cask block found' # verify the path points at a cask, not a formula or empty file end
Prevention
- Assert the target file matches /^cask / before extraction
- Double-check tap paths and env vars (MISE_BREW_TOKEN, CASK_FILE)
- Handle tap layout changes that relocate cask files
- Treat empty or suspiciously small cask files as errors early
When it happens
Trigger: The file piped to STDIN and eval'd contains no top-level `cask '<token>' do ... end` block — e.g. it's a formula (.rb formula), an unrelated Ruby file, an empty/truncated file, or the cask DSL itself failed earlier in a way that skipped the block.
Common situations: Pointing the tap metadata extraction at a formula instead of a cask; wrong file path/env var so an empty file is read; cask file that wraps everything in conditionals the top-level binding doesn't execute; tap layout changes moving casks to new paths.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- cask has no version
- cask has no URL
- unsupported cask metadata DSL `#{name}`
- no precompiled ruby is available for this platform To compil
- Ruby engine '{}' is not supported on Windows. Only standard
AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09).
Data as JSON: /api/errors/a1e7cd11ceec6020.
Report an issue: GitHub.