Skip to content

Resolve src through realpath in install_renamed#22351

Merged
MikeMcQuaid merged 4 commits into
Homebrew:mainfrom
dariaguy:install-renamed-src-realpath
May 20, 2026
Merged

Resolve src through realpath in install_renamed#22351
MikeMcQuaid merged 4 commits into
Homebrew:mainfrom
dariaguy:install-renamed-src-realpath

Conversation

@dariaguy
Copy link
Copy Markdown

Fixing untouched etc configs being left stale on upgrade.
After the new keg is linked, Formula#prefix returns opt_prefix, so the ascend in append_default_if_different walks via the opt/ symlink and the HOMEBREW_CELLAR guard rejects every level — the sibling-keg lookup never runs and <file>.default is always written. Resolving src through realpath first puts the walk back on the cellar path so the lookup fires and untouched configs can advance on upgrade.

Tested locally by adding a line to a conf in https://github.com/redis-developer/homebrew-core/blob/redis-add-line-to-conf/Formula/r/redis.rb, created a bottle and ran brew upgrade redis


  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes. Non-maintainers may only have one AI-assisted/generated PR open at a time.
    Used claude, verified manually the fix

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a regression in InstallRenamed#append_default_if_different where, after a keg is opt-linked, the logic that detects “unchanged config matching an older bottled default” fails to locate sibling kegs in the Cellar, causing *.default files to be written unnecessarily and leaving untouched configs stale on upgrade.

Changes:

  • Resolve the src path through realpath before ascend so the walk is based on the Cellar path rather than opt_prefix.
  • Add a new spec covering the opt-linked keg upgrade scenario for Formula#install_etc_var.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
Library/Homebrew/install_renamed.rb Adjusts path resolution in append_default_if_different to make sibling-keg lookup work when the keg is opt-linked.
Library/Homebrew/test/formula_spec.rb Adds a test reproducing the opt-linked keg scenario and asserting config replacement behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/install_renamed.rb Outdated
Comment thread Library/Homebrew/install_renamed.rb Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread Library/Homebrew/install_renamed.rb
Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dariaguy, looks good and appreciate you taking the time to do this!

@MikeMcQuaid MikeMcQuaid enabled auto-merge May 20, 2026 13:59
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue May 20, 2026
Merged via the queue into Homebrew:main with commit 9531a0c May 20, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants