Add symlinked home detection to brew doctor on Linux

Co-authored-by: MikeMcQuaid <125011+MikeMcQuaid@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-08-12 11:00:14 +01:00 committed by Mike McQuaid
parent b8c82b44b8
commit d785e2024b
No known key found for this signature in database
2 changed files with 30 additions and 0 deletions

View File

@ -10,6 +10,7 @@ require "os/linux/kernel"
module OS
module Linux
module Diagnostic
# Linux-specific diagnostic checks for Homebrew.
module Checks
extend T::Helpers
@ -28,6 +29,7 @@ module OS
check_glibc_minimum_version
check_kernel_minimum_version
check_supported_architecture
check_for_symlinked_home
].freeze
end
@ -154,6 +156,27 @@ module OS
EOS
end
def check_for_symlinked_home
return unless File.symlink?("/home")
<<~EOS
Your /home directory is a symlink.
This is known to cause issues with formula linking, particularly when installing
multiple formulae that create symlinks in shared directories.
While this may be a standard directory structure in some distributions
(e.g. Fedora Silverblue) there are known issues as-is.
If you encounter linking issues, you may need to manually create conflicting
directories or use `brew link --overwrite` as a workaround.
We'd welcome a PR to fix this functionality.
See https://github.com/Homebrew/brew/issues/18036 for more context.
#{support_tier_message(tier: 2)}
EOS
end
def check_gcc_dependent_linkage
gcc_dependents = ::Formula.installed.select do |formula|
next false unless formula.tap&.core_tap?

View File

@ -25,4 +25,11 @@ RSpec.describe Homebrew::Diagnostic::Checks do
expect(checks.check_kernel_minimum_version)
.to match(/Your Linux kernel .+ is too old/)
end
specify "#check_for_symlinked_home" do
allow(File).to receive(:symlink?).with("/home").and_return(true)
expect(checks.check_for_symlinked_home)
.to match(%r{Your /home directory is a symlink})
end
end