jdx/mise · error · RuntimeError

undefined resource #{name.inspect}

Error message

undefined resource #{name.inspect}

What it means

Formula#resource looks up a named Resource declared on the formula's class via self.class.resources. It raises when the requested name isn't in that map, i.e. the formula never declared a resource with that name (or the name is misspelled).

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 afd2eddd3a)

Solutions

  1. Declare the resource in the formula: resource "name" do ... end
  2. Fix the name used in resource(...) to match the declared resource exactly
  3. Check the resource is declared in the version branch being installed
  4. Use resources to list available resource names for debugging

Example fix

# before
resource("my-data").stage(pkgshare)
# after
resource "my-data" do
  url "https://example.com/my-data.tar.gz"
  sha256 "abc"
end
# ...then in install:
resource("my-data").stage(pkgshare)
Defensive patterns

Strategy: validation

Validate before calling

unless formula.class.resources.key?("my-data")
  raise "formula #{formula.name} does not declare resource my-data"
end

Prevention

When it happens

Trigger: Calling resource("name") during install for a resource not declared in the formula; misspelled resource name; resources declared only for a different stable/head block so they're absent at install time.

Common situations: Formula refactors that removed a resource while install blocks still reference it; version-conditional resource declarations where the installed version lacks the resource; typos between resource declarations and uses.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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