{"record":{"id":"5efd2cc5b1cdffea","repo":"jdx/mise","slug":"inreplace-in-path-made-no-substitutions-the-f","errorCode":null,"errorMessage":"inreplace in #{path} made no substitutions — the formula may need updating","messagePattern":"inreplace in #(.+?) made no substitutions — the formula may need updating","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/shim.rb","lineNumber":777,"sourceCode":"\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\n      replaced = content.dup\n      if block\n        ext = InreplaceText.new(replaced)\n        block.call(ext)\n        replaced = ext.text\n      else\n        raise \"inreplace: missing before/after\" if before.nil?\n        case before\n        when Regexp then replaced.gsub!(before, after.to_s)\n        else replaced = replaced.gsub(before.to_s, after.to_s)\n        end\n      end\n      if audit_result && replaced == content\n        raise \"inreplace in #{path} made no substitutions — the formula may need updating\"\n      end\n      path.write(replaced)\n    end\n  end\n\n  def cd(path, &block) = Dir.chdir(path.to_s, &block)\n\n  def mkdir(name, &block)\n    path = Pathname.new(name.to_s)\n    path.mkpath\n    block ? Dir.chdir(path.to_s, &block) : path\n  end\n\n  def loader_path = OS.mac? ? \"@loader_path\" : \"$ORIGIN\"\n\n  def rpath(source: bin, target: lib)\n    \"#{loader_path}/#{Pathname.new(target.to_s).relative_path_from(Pathname.new(source.to_s))}\"\n  end","sourceCodeStart":759,"sourceCodeEnd":795,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/brew/shim.rb#L759-L795","documentation":"inreplace audits its result: when audit_result is set and the file content is unchanged after substitution, it assumes the pattern no longer matches (likely due to an upstream change) and raises so stale formulas fail loudly instead of silently no-op'ing.","triggerScenarios":"Calling `inreplace path, before, after` with audit enabled where `before` does not appear in the file — upstream renamed the setting, changed formatting/whitespace, or a prior inreplace already replaced it.","commonSituations":"Formula pinned to a new source version whose Makefile/config text differs; pattern written with wrong quoting or escaping; running the replace twice in the same build.","solutions":["Inspect the target file in the stage dir and update the before-pattern to match current text.","Disable the audit only if a no-op substitution is acceptable.","Remove the inreplace if upstream already contains the desired change.","Broaden the pattern (e.g. a Regexp tolerant of whitespace)."],"exampleFix":"# before\ninreplace \"config.mk\", \"PREFIX = /usr/local\", \"PREFIX = #{prefix}\"\n# after (upstream now writes 'PREFIX?=/usr/local')\ninreplace \"config.mk\", /^PREFIX\\s*\\??=.*$/, \"PREFIX = #{prefix}\"","handlingStrategy":"validation","validationCode":"content = File.read(path)\nraise \"pattern not found in #{path}\" unless content.include?(before)","typeGuard":null,"tryCatchPattern":"begin\n  inreplace path, before, after, audit_result: true\nrescue RuntimeError => e\n  raise unless e.message.include?(\"made no substitutions\")\n  # update pattern against current file text\nend","preventionTips":["Verify the before-string exists in the current source before replacing","Re-verify patterns on every version bump","Prefer whitespace-tolerant regexps over exact strings","Avoid double-applying the same inreplace"],"tags":["ruby","brew-shim","inreplace","formula"],"backgroundTag":"substitution-made-no-changes","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"}