{"record":{"id":"5033474c453e90fa","repo":"jdx/mise","slug":"undefined-resource-name-inspect","errorCode":null,"errorMessage":"undefined resource #{name.inspect}","messagePattern":"undefined resource #(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/shim.rb","lineNumber":731,"sourceCode":"  def doc = share + \"doc\" + name\n  def info = share + \"info\"\n  def bash_completion = prefix + \"etc/bash_completion.d\"\n  def zsh_completion = share + \"zsh/site-functions\"\n  def fish_completion = share + \"fish/vendor_completions.d\"\n  def pkgetc = etc + name\n\n  # etc/var live in the prefix, outside the keg (survive upgrades)\n  def etc = MISE_BREW_PREFIX + \"etc\"\n  def var = MISE_BREW_PREFIX + \"var\"\n\n  def buildpath = MISE_BREW_BUILDPATH\n  def testpath = shim_unsupported!(\"testpath\")\n\n  def deps = []\n  def declared_deps = []\n\n  def resource(name)\n    res = self.class.resources.fetch(name) { raise \"undefined resource #{name.inspect}\" }\n    res.owner = self\n    res\n  end\n\n  def resources = self.class.resources.values.each { |r| r.owner = self }\n\n  # ---- build helpers ----\n  def system(cmd, *args)\n    args = args.map(&:to_s)\n    pretty = ([cmd] + args).join(\" \")\n    ohai pretty\n    # single-string invocations go through the shell, like Kernel#system\n    ok = Kernel.system(cmd.to_s, *args)\n    raise \"command failed: #{pretty}\" unless ok\n  end\n\n  def quiet_system(cmd, *args)\n    Kernel.system(cmd.to_s, *args.map(&:to_s), out: File::NULL, err: File::NULL)","sourceCodeStart":713,"sourceCodeEnd":749,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/brew/shim.rb#L713-L749","documentation":"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.","triggerScenarios":"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.","commonSituations":"Upstream renamed a vendored dependency; typo like `resource(\"extra\")` vs declared `resource \"extras\"`; ported install block referencing resources from a different formula.","solutions":["Fix the name passed to resource() to match a declared resource block exactly.","Declare the missing `resource \"name\" do url ... sha256 ... end` in the formula.","Remove the resource(...) call if the dependency is no longer used.","Inspect formula.class.resources to list valid names during debugging."],"exampleFix":"# before\nresource(\"nested-dep\").stage do |r|\n  r.install \"lib\"\nend\n# after\nresource(\"nested_deps\").stage do |r|\n  r.install \"lib\"\nend  # matches the declared resource name","handlingStrategy":"validation","validationCode":"raise \"unknown resource #{name}\" unless formula.class.resources.key?(name)\nres = formula.resource(name)","typeGuard":null,"tryCatchPattern":"begin\n  res = formula.resource(name)\nrescue KeyError, RuntimeError => e\n  raise unless e.message.include?(\"undefined resource\")\n  # fix name or declare the resource\nend","preventionTips":["Keep resource names in a constant shared by declaration and install block","Grep install blocks for resource( calls and cross-check declarations","Update resource references whenever renaming resources"],"tags":["ruby","brew-shim","resource","lookup"],"backgroundTag":"record-not-found","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}