jdx/mise · error · RuntimeError

resource #{name}: stage requires a target or a block

Error message

resource #{name}: stage requires a target or a block

What it means

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.

Source

Thrown at src/system/packages/brew/shim.rb:429

    # artifact — refuse instead
    shim_unsupported!("resource patches")
  end

  # unpack into `target` (or a tmpdir) and run the optional block there
  def stage(target = nil, &block)
    shim_unsupported!("resource with download strategy #{using.inspect}") unless using.nil?
    raise "resource #{name}: missing url" if @url.nil?
    archive = MiseDownload.fetch(@url, @sha256, "resource #{name}")
    if target
      target = Pathname.new(target.to_s)
      stage_dir = Pathname.new(Dir.mktmpdir("mise-resource-"))
      root = MiseDownload.unpack(archive, stage_dir)
      target.mkpath
      FileUtils.cp_r("#{root}/.", target.to_s)
      FileUtils.remove_entry(stage_dir)
      block&.call(self)
    else
      raise "resource #{name}: stage requires a target or a block" unless block
      Dir.mktmpdir("mise-resource-") do |dir|
        root = MiseDownload.unpack(archive, Pathname.new(dir))
        Dir.chdir(root) { block.call(self) }
      end
    end
  end
end

class PatchSpec
  def initialize(strip, formula_file)
    @strip = strip
    @formula_file = formula_file
  end

  def url(url = nil, **)
    @url = url unless url.nil?
    @url
  end

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Pass a target Pathname: resource.stage(libexec)
  2. Or pass a block: resource.stage { |r| ... }
  3. If the intent was 'stage into buildpath', pass buildpath explicitly

Example fix

# before
resource("data").stage
# after
resource("data").stage(pkgshare) do |r|
  # post-stage work
end
Defensive patterns

Strategy: validation

Validate before calling

raise "stage needs target or block" if target.nil? && !block_given?

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09). Data as JSON: /api/errors/59919cbdaa24c21a. Report an issue: GitHub.