{"record":{"id":"45360f33de15116a","repo":"jdx/mise","slug":"command-failed-pretty","errorCode":null,"errorMessage":"command failed: #{pretty}","messagePattern":"command failed: #(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/shim.rb","lineNumber":745,"sourceCode":"  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)\n  end\n\n  def which(cmd)\n    ENV.fetch(\"PATH\", \"\").split(File::PATH_SEPARATOR).each do |dir|\n      candidate = Pathname.new(dir) + cmd.to_s\n      return candidate if candidate.executable? && candidate.file?\n    end\n    nil\n  end\n\n  def inreplace(paths, before = nil, after = nil, audit_result = true, &block)\n    Array(paths).each do |path|\n      path = Pathname.new(path.to_s)\n      content = path.read","sourceCodeStart":727,"sourceCodeEnd":763,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/packages/brew/shim.rb#L727-L763","documentation":"The shim overrides Kernel#system so formula scripts get ohai logging and fail-fast semantics. It raises when the invoked command exits non-zero, halting the formula's install at the first failing command with the full command line in the message.","triggerScenarios":"Any build/test/install command invoked via system(...) that exits with a failure status: missing build tool, configure script error, failing make target, missing interpreter, bad flags.","commonSituations":"Build dependencies not present in the shim environment; configure detecting a missing library and exiting 1; commands assuming Homebrew paths (e.g. HOMEBREW_PREFIX) that the shim doesn't provide; typo'd flags in the formula.","solutions":["Run the failing command manually in the stage dir to see its full error output","Install or expose the missing build dependency the command needs","Fix wrong flags/paths in the formula's system(...) invocation","Use quiet_system or inreplace alternatives where shell behavior differs"],"exampleFix":"# before\nsystem \"make\", \"install\"\n# after\nraise \"make install failed\" unless quiet_system \"make\", \"install\"\nsystem \"make\", \"install\"","handlingStrategy":"try-catch","validationCode":"# preflight: ensure required tools exist before running formula build\n%w[make gcc].each { |t| raise \"missing tool #{t}\" unless system(\"which\", t, out: File::NULL) }","typeGuard":null,"tryCatchPattern":"begin\n  system \"make\", \"install\"\nrescue RuntimeError => e\n  warn \"install step failed: #{e.message}\"\n  raise\nend","preventionTips":["Run failing commands manually in the stage dir for full output","Declare/verify all build dependencies before build steps","Avoid commands that assume Homebrew-specific env vars","Keep command flags current with the tool version being built"],"tags":["subprocess","command-failed","ruby"],"backgroundTag":"command-failed","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}