{"record":{"id":"59919cbdaa24c21a","repo":"jdx/mise","slug":"resource-name-stage-requires-a-target-or-a-blo","errorCode":null,"errorMessage":"resource #{name}: stage requires a target or a block","messagePattern":"resource #(.+?): stage requires a target or a block","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/shim.rb","lineNumber":429,"sourceCode":"    # artifact — refuse instead\n    shim_unsupported!(\"resource patches\")\n  end\n\n  # unpack into `target` (or a tmpdir) and run the optional block there\n  def stage(target = nil, &block)\n    shim_unsupported!(\"resource with download strategy #{using.inspect}\") unless using.nil?\n    raise \"resource #{name}: missing url\" if @url.nil?\n    archive = MiseDownload.fetch(@url, @sha256, \"resource #{name}\")\n    if target\n      target = Pathname.new(target.to_s)\n      stage_dir = Pathname.new(Dir.mktmpdir(\"mise-resource-\"))\n      root = MiseDownload.unpack(archive, stage_dir)\n      target.mkpath\n      FileUtils.cp_r(\"#{root}/.\", target.to_s)\n      FileUtils.remove_entry(stage_dir)\n      block&.call(self)\n    else\n      raise \"resource #{name}: stage requires a target or a block\" unless block\n      Dir.mktmpdir(\"mise-resource-\") do |dir|\n        root = MiseDownload.unpack(archive, Pathname.new(dir))\n        Dir.chdir(root) { block.call(self) }\n      end\n    end\n  end\nend\n\nclass PatchSpec\n  def initialize(strip, formula_file)\n    @strip = strip\n    @formula_file = formula_file\n  end\n\n  def url(url = nil, **)\n    @url = url unless url.nil?\n    @url\n  end","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/packages/brew/shim.rb#L411-L447","documentation":"Resource#stage requires either a target directory argument or a block to consume the unpacked contents. It raises when stage is called with neither, since there is nowhere to put the unpacked archive and no code to process it.","triggerScenarios":"Calling resource.stage() with no arguments and no block; refactorings that dropped the block but kept the stage call; formula code assuming stage defaults to a directory like Homebrew's newer behavior.","commonSituations":"Ported Homebrew formula snippets that call resource.stage expecting implicit staging into the buildpath; partial ports of formula Ruby code into the shim's supported DSL subset.","solutions":["Pass a target Pathname: resource.stage(libexec)","Or pass a block: resource.stage { |r| ... }","If the intent was 'stage into buildpath', pass buildpath explicitly"],"exampleFix":"# before\nresource(\"data\").stage\n# after\nresource(\"data\").stage(pkgshare) do |r|\n  # post-stage work\nend","handlingStrategy":"validation","validationCode":"raise \"stage needs target or block\" if target.nil? && !block_given?","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass a target directory or a block to resource.stage","Avoid assuming Homebrew's implicit staging defaults","Wrap stage calls in small helpers with explicit targets"],"tags":["ruby","api-usage","resource"],"backgroundTag":"missing-required-argument","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}