jdx/mise · error · RuntimeError
inreplace in #{path} made no substitutions — the formula may
Error message
inreplace in #{path} made no substitutions — the formula may need updating What it means
inreplace audits its own result: if the file content after replacement is identical to before (audit_result enabled), the search pattern matched nothing. The shim raises to surface stale patches early — typically because upstream changed and the formula's search string no longer exists.
Source
Thrown at src/system/packages/brew/shim.rb:777
def inreplace(paths, before = nil, after = nil, audit_result = true, &block)
Array(paths).each do |path|
path = Pathname.new(path.to_s)
content = path.read
replaced = content.dup
if block
ext = InreplaceText.new(replaced)
block.call(ext)
replaced = ext.text
else
raise "inreplace: missing before/after" if before.nil?
case before
when Regexp then replaced.gsub!(before, after.to_s)
else replaced = replaced.gsub(before.to_s, after.to_s)
end
end
if audit_result && replaced == content
raise "inreplace in #{path} made no substitutions — the formula may need updating"
end
path.write(replaced)
end
end
def cd(path, &block) = Dir.chdir(path.to_s, &block)
def mkdir(name, &block)
path = Pathname.new(name.to_s)
path.mkpath
block ? Dir.chdir(path.to_s, &block) : path
end
def loader_path = OS.mac? ? "@loader_path" : "$ORIGIN"
def rpath(source: bin, target: lib)
"#{loader_path}/#{Pathname.new(target.to_s).relative_path_from(Pathname.new(source.to_s))}"
endView on GitHub (pinned to afd2eddd3a)
Solutions
- Update the search string to match the current file content (inspect the file)
- Read the target file to confirm the pattern exists and its exact spelling
- Make the before pattern more tolerant (use a Regexp) or guard with a conditional inreplace only when needed
- Ensure inreplace isn't applied twice to the same file in one install
Example fix
# before
inreplace "config.mk", "CC = gcc", "CC = #{ENV["CC"]}"
# after
inreplace "config.mk", /^CC\s*=\s*\S+$/, "CC = #{ENV["CC"]}" Defensive patterns
Strategy: validation
Validate before calling
content = File.read(path)
raise "pattern not found in #{path}" unless content.include?(search)
inreplace(path, search, replacement) Try / catch
begin
inreplace f, old, new
rescue RuntimeError => e
raise unless e.message.include?("made no substitutions")
warn "formula needs updating: #{e.message}"
end Prevention
- Verify the search string exists in the file on every version bump
- Use tolerant regexes instead of exact strings where formatting varies
- Never run inreplace twice on the same content
- Read the target file when updating a formula to refresh search patterns
When it happens
Trigger: The `before` string/regex no longer appears in the file (upstream refactor); the file path is empty or already rewritten; case/formatting drift in the target text; running inreplace twice on the same file.
Common situations: Version bumps where the edited config file changed format; formulas editing generated files whose content varies by platform or toolchain version; patches kept across many versions until they silently stop matching.
Related errors
- inreplace: missing before/after
- formula declares a DATA patch but has no __END__ section
- undefined resource #{name.inspect}
- no precompiled ruby is available for this platform To compil
- Ruby engine '{}' is not supported on Windows. Only standard
AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09).
Data as JSON: /api/errors/5efd2cc5b1cdffea.
Report an issue: GitHub.