jdx/mise · error · RuntimeError
inreplace in # made no substitutions — the formula may need…
Error message
inreplace in #{path} made no substitutions — the formula may need updating What it means
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.
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).
Example fix
# before
inreplace "config.mk", "PREFIX = /usr/local", "PREFIX = #{prefix}"
# after (upstream now writes 'PREFIX?=/usr/local')
inreplace "config.mk", /^PREFIX\s*\??=.*$/, "PREFIX = #{prefix}" Defensive patterns
Strategy: validation
Validate before calling
content = File.read(path)
raise "pattern not found in #{path}" unless content.include?(before) Try / catch
begin
inreplace path, before, after, audit_result: true
rescue RuntimeError => e
raise unless e.message.include?("made no substitutions")
# update pattern against current file text
end Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- formula declares a DATA patch but has no __END__ section
- inreplace: missing before/after
- cannot install # : does not exist
- command failed: #
- completion generation failed: #
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/5efd2cc5b1cdffea.
Report an issue: GitHub.
Appendix: 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 533346cc37)