jdx/mise · error · RuntimeError
inreplace: # not found
Error message
inreplace: #{before.inspect} not found What it means
Raised by the Inreplace helper's gsub! when the search pattern does not occur in the text being patched and the audit_result flag is true (the default). mise's brew shim uses this class to apply small textual patches to Homebrew formulae/casks during source builds, and it treats a non-matching pattern as an error because a silent no-op patch would produce an unmodified build. It guards against formulae whose content changed upstream so a patch would be silently skipped.
Solutions
- Update or remove the stale patch/pattern so it matches the current formula/cask contents
- Pin the tool to a formula/cask version the patch was written for
- Inspect the target file and adjust the regex to tolerate formatting differences (whitespace, quoting)
- Pass audit_result=false only if a no-op patch is intentionally acceptable
Example fix
# before
f.gsub!("depends_on \"openssl@1.1\"", "depends_on \"openssl@3\"")
# after
if f.text.include?("depends_on \"openssl@1.1\"")
f.gsub!("depends_on \"openssl@1.1\"", "depends_on \"openssl@3\"")
else
# formula already updated; skip patch
end Defensive patterns
Strategy: validation
Validate before calling
raise "patch target missing" unless inreplace.text.include?(pattern) inreplace.gsub!(pattern, replacement)
Type guard
def patchable?(inreplace, pattern) = !inreplace.text.scan(pattern).empty?
Try / catch
begin
f.gsub!(pattern, replacement)
rescue RuntimeError => e
raise unless e.message.start_with?("inreplace:")
warn "patch no longer applies: #{e.message}; skipping"
end Prevention
- Anchor patches to version-stable text and re-check after every formula update
- Prefer narrow, unique patterns and verify with include? before gsub!
- Pass audit_result=false only for truly optional patches
- Test the shim against the exact formula revision being installed
When it happens
Trigger: Calling gsub!(pattern, replacement) on an Inreplace where the pattern is absent from the text; the source formula/cask was updated upstream so the expected line or string no longer exists; a patch written for one formula version is applied to a different version; passing audit_result=false avoids the raise but returns nil instead.
Common situations: Building a tool from source via a brew tap after Homebrew updated the formula; a pinned patch in mise's brew shim drifting from the current formula contents; typos or over-specific regexes that fail on whitespace/quote variants of the expected text.
Related errors
- ruby-build version regex
- cannot install # : does not exist
- cask has no URL
- cask has no version
- command failed: #
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/ba6843212c44667e.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/packages/brew/shim.rb:877
def time = Time.now
def post_install; end
# unknown instance helpers: fail loudly
def method_missing(name, *args, &block)
shim_unsupported!("#{name} (install-time helper)")
end
def respond_to_missing?(_name, _include_private = false) = true
class InreplaceText
attr_reader :text
def initialize(text) = @text = text
def gsub!(before, after, audit_result = true)
result = @text.gsub!(before, after.to_s)
raise "inreplace: #{before.inspect} not found" if result.nil? && audit_result
result
end
def sub!(before, after)
@text.sub!(before, after.to_s)
end
def change_make_var!(flag, new_value)
replaced = @text.gsub!(/^#{Regexp.escape(flag)}[ \t]*[\\?\\+\\:]?=[ \t]*((?:.*\\\n)*.*)$/, "#{flag}=#{new_value}")
opoo "change_make_var! #{flag} did nothing" if replaced.nil?
replaced
end
end
end
def main
load MISE_BREW_FORMULA_FILE.to_s
klass = Formula.instance_variable_get(:@formula_subclass)View on GitHub (pinned to 533346cc37)