jdx/mise · error · RuntimeError

resource # : missing url

Error message

resource #{name}: missing url

What it means

Homebrew shim's Resource#stage path: the embedded brew Formula DSL shim does not implement full resource download strategies, and a resource defined without a url cannot be staged or version-inferred by the shim, so it refuses rather than producing a wrong artifact.

Solutions

  1. Add the missing `url` (and matching `sha256`) to the resource block in the formula.
  2. Remove the resource and its stage call if the component is no longer needed.
  3. If the url is conditional, ensure the stage call is inside the same condition.

Example fix

# before
resource "libfoo" do
  version "1.2"
end
# after
resource "libfoo" do
  url "https://example.com/libfoo-1.2.tar.gz"
  sha256 "abc123..."
  version "1.2"
end
Defensive patterns

Strategy: validation

Validate before calling

raise "resource #{r.name}: no url" if r.url.nil?  # before calling stage

Try / catch

begin
  resource.stage(target)
rescue RuntimeError => e
  raise unless e.message.include?("missing url")
  # add url to resource or skip
end

Prevention

When it happens

Trigger: Declaring `resource "name" do ... end` without a `url` directive and then calling `stage(target)` or `stage { |r| ... }` on it.

Common situations: Copy-pasted resource blocks where the url line was dropped; formula updates where upstream removed a sub-component but the formula still stages it; conditional resources defined only in one branch but staged unconditionally.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/1fe510ac560d434f. Report an issue: GitHub.

Appendix: source

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

  def version(version = nil)
    @version = version unless version.nil?
    @version || (@url && Version.new(@url[/[0-9]+(?:\.[0-9]+)+/].to_s))
  end

  def mirror(url) = (@mirrors ||= []) << url
  def using = @specs[:using]
  def livecheck(&) = nil

  def patch(*, &)
    # building against an unpatched resource silently produces a wrong
    # 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

View on GitHub (pinned to 533346cc37)