Skip to content

Commit 9531a0c

Browse files
authored
Merge pull request #22351 from dariaguy/install-renamed-src-realpath
Resolve src through realpath in install_renamed
2 parents 53f3a89 + 4539de6 commit 9531a0c

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

Library/Homebrew/install_renamed.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ def append_default_if_different(src, dst)
4848
# helper. If the live config still matches an older bottled default, replace
4949
# it so untouched configs advance on upgrade. Modified configs still receive
5050
# the new default as `*.default`.
51+
# Resolve via realpath so the ascend walks the Cellar path, not `opt_prefix`.
52+
# For symlink sources, resolve only the parent directory so broken symlinks
53+
# are still handled without requiring the target to exist.
54+
src = if src.symlink?
55+
src.dirname.realpath/src.basename
56+
else
57+
src.realpath
58+
end
5159
src.ascend do |path|
5260
next if path.basename.to_s != ".bottle" || path.parent.parent.parent != HOMEBREW_CELLAR
5361

Library/Homebrew/test/formula_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,15 @@ def post_install
11211121

11221122
expect([config_file.read, default_config_file.read]).to eq(["custom\n", "new\n"])
11231123
end
1124+
1125+
it "replaces config that matches the previous default when the keg is opt-linked" do
1126+
config_file.write "old\n"
1127+
Keg.new(f.rack/"2.0").optlink
1128+
1129+
f.install_etc_var
1130+
1131+
expect([config_file.read, default_config_file.exist?]).to eq(["new\n", false])
1132+
end
11241133
end
11251134

11261135
specify "test fixtures" do

0 commit comments

Comments
 (0)