{"record":{"id":"a1e7cd11ceec6020","repo":"jdx/mise","slug":"no-cask-block-found","errorCode":null,"errorMessage":"no cask block found","messagePattern":"no cask block found","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/tap_cask_metadata.rb","lineNumber":341,"sourceCode":"    collector.instance_eval(&block)\n    @artifacts << { kind => [{ \"steps\" => collector.steps }] }\n  end\n\n  def add_artifact(kind, source, target)\n    value = [source.to_s]\n    value << { \"target\" => target.to_s } unless target.nil?\n    @artifacts << { kind => value }\n  end\nend\n\ndef cask(token, &block)\n  $mise_cask_metadata = CaskMetadata.new(token)\n  $mise_cask_metadata.instance_eval(&block)\nend\n\neval(STDIN.read.force_encoding(\"UTF-8\"), TOPLEVEL_BINDING, CASK_FILE, 1)\nmetadata = $mise_cask_metadata\nraise \"no cask block found\" if metadata.nil?\nexpected = ENV.fetch(\"MISE_BREW_TOKEN\")\nraise \"expected cask #{expected}, got #{metadata.token}\" if metadata.token != expected\nputs JSON.generate(metadata.to_h)\n","sourceCodeStart":323,"sourceCodeEnd":345,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/brew/tap_cask_metadata.rb#L323-L345","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before (cask)\ncask \"foo\" do\n  version \"1.0\"\nend if OS.mac?\n# after (cask)\ncask \"foo\" do\n  version \"1.0\"\nend","handlingStrategy":"validation","validationCode":"raise \"not a cask file\" unless File.read(path).match?(/^\\s*cask\\s+[\"'][^\"']+[\"']\\s+do/)","typeGuard":"def cask_file?(path) = !!(File.read(path) =~ /^\\s*cask\\s+[\"'][^\"']+[\"']\\s+do/)","tryCatchPattern":"begin\n  metadata = parse_cask_metadata(cask_source)\nrescue RuntimeError => e\n  raise unless e.message == \"no cask block found\"\n  warn \"#{cask_path} contains no cask block; check MISE_BREW_SOURCE_PATH\"\nend","preventionTips":["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"],"tags":["ruby","cask","parse-failure","missing-block"],"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"}