jdx/mise · error · RuntimeError

undefined resource #

Error message

undefined resource #{name.inspect}

What it means

Formula#resource looks up a named resource declared in the formula's class and raises when no resource with that name exists. The returned resource is marked with its owner so subsequent stage/install calls work.

Solutions

  1. Fix the name passed to resource() to match a declared resource block exactly.
  2. Declare the missing `resource "name" do url ... sha256 ... end` in the formula.
  3. Remove the resource(...) call if the dependency is no longer used.
  4. Inspect formula.class.resources to list valid names during debugging.

Example fix

# before
resource("nested-dep").stage do |r|
  r.install "lib"
end
# after
resource("nested_deps").stage do |r|
  r.install "lib"
end  # matches the declared resource name
Defensive patterns

Strategy: validation

Validate before calling

raise "unknown resource #{name}" unless formula.class.resources.key?(name)
res = formula.resource(name)

Try / catch

begin
  res = formula.resource(name)
rescue KeyError, RuntimeError => e
  raise unless e.message.include?("undefined resource")
  # fix name or declare the resource
end

Prevention

When it happens

Trigger: Calling `resource("name")` inside the install block where the formula declares no such resource, or the name is misspelled; resources were removed/renamed in a formula update while install code still references them.

Common situations: Upstream renamed a vendored dependency; typo like `resource("extra")` vs declared `resource "extras"`; ported install block referencing resources from a different formula.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

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

  def doc = share + "doc" + name
  def info = share + "info"
  def bash_completion = prefix + "etc/bash_completion.d"
  def zsh_completion = share + "zsh/site-functions"
  def fish_completion = share + "fish/vendor_completions.d"
  def pkgetc = etc + name

  # etc/var live in the prefix, outside the keg (survive upgrades)
  def etc = MISE_BREW_PREFIX + "etc"
  def var = MISE_BREW_PREFIX + "var"

  def buildpath = MISE_BREW_BUILDPATH
  def testpath = shim_unsupported!("testpath")

  def deps = []
  def declared_deps = []

  def resource(name)
    res = self.class.resources.fetch(name) { raise "undefined resource #{name.inspect}" }
    res.owner = self
    res
  end

  def resources = self.class.resources.values.each { |r| r.owner = self }

  # ---- build helpers ----
  def system(cmd, *args)
    args = args.map(&:to_s)
    pretty = ([cmd] + args).join(" ")
    ohai pretty
    # single-string invocations go through the shell, like Kernel#system
    ok = Kernel.system(cmd.to_s, *args)
    raise "command failed: #{pretty}" unless ok
  end

  def quiet_system(cmd, *args)
    Kernel.system(cmd.to_s, *args.map(&:to_s), out: File::NULL, err: File::NULL)

View on GitHub (pinned to 533346cc37)