Module: OS::Linux::Diagnostic::Checks Private

Extended by:
T::Helpers
Included in:
Homebrew::Diagnostic::Checks
Defined in:
extend/os/linux/diagnostic.rb

Overview

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Linux-specific diagnostic checks for Homebrew.

Instance Method Summary collapse

Instance Method Details

#check_cask_software_versionsString?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



229
230
231
232
233
234
# File 'extend/os/linux/diagnostic.rb', line 229

def check_cask_software_versions
  super
  add_info "Linux", OS::Linux.os_version

  nil
end

#check_for_symlinked_homeString?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'extend/os/linux/diagnostic.rb', line 170

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

#check_gcc_dependent_linkageString?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'extend/os/linux/diagnostic.rb', line 192

def check_gcc_dependent_linkage
  gcc_dependents = ::Formula.installed.select do |formula|
    next false unless formula.tap&.core_tap?

    # FIXME: This includes formulae that have no runtime dependency on GCC.
    formula.recursive_dependencies.map(&:name).include? "gcc"
  rescue TapFormulaUnavailableError
    false
  end
  return if gcc_dependents.empty?

  badly_linked = gcc_dependents.select do |dependent|
    dependent_prefix = dependent.any_installed_prefix
    # Keg.new() may raise an error if it is not a directory.
    # As the result `brew doctor` may display `Error: <keg> is not a directory`
    # instead of proper `doctor` information.
    # There are other checks that test that, we can skip broken kegs.
    next if dependent_prefix.nil? || !dependent_prefix.exist? || !dependent_prefix.directory?

    keg = Keg.new(dependent_prefix)
    keg.binary_executable_or_library_files.any? do |binary|
      paths = binary.rpaths
      versioned_linkage = paths.any? { |path| path.match?(%r{lib/gcc/\d+$}) }
      unversioned_linkage = paths.any? { |path| path.match?(%r{lib/gcc/current$}) }

      versioned_linkage && !unversioned_linkage
    end
  end
  return if badly_linked.empty?

  inject_file_list badly_linked, <<~EOS
    Formulae which link to GCC through a versioned path were found. These formulae
    are prone to breaking when GCC is updated. You should `brew reinstall` these formulae:
  EOS
end

#check_glibc_minimum_versionString?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'extend/os/linux/diagnostic.rb', line 96

def check_glibc_minimum_version
  return unless OS::Linux::Glibc.below_minimum_version?

  <<~EOS
    Your system glibc #{OS::Linux::Glibc.system_version} is too old.
    We only support glibc #{OS::Linux::Glibc.minimum_version} or later.

    We recommend updating to a newer version via your distribution's
    package manager, upgrading your distribution to the latest version,
    or changing distributions.

    #{support_tier_message(tier: :unsupported)}
  EOS
end

#check_glibc_versionString?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'extend/os/linux/diagnostic.rb', line 112

def check_glibc_version
  return unless OS::Linux::Glibc.below_ci_version?

  # We want to bypass this check in some tests.
  return if ENV["HOMEBREW_GLIBC_TESTING"]

  <<~EOS
    Your system glibc #{OS::Linux::Glibc.system_version} is too old.
    We will need to automatically install a newer version.

    We recommend updating to a newer version via your distribution's
    package manager, upgrading your distribution to the latest version,
    or changing distributions.

    #{support_tier_message(tier: 2)}
  EOS
end

#check_kernel_minimum_versionString?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'extend/os/linux/diagnostic.rb', line 131

def check_kernel_minimum_version
  return unless OS::Linux::Kernel.below_minimum_version?

  <<~EOS
    Your Linux kernel #{OS.kernel_version} is too old.
    We only support kernel #{OS::Linux::Kernel.minimum_version} or later.
    You will be unable to use binary packages (bottles).

    We recommend updating to a newer version via your distribution's
    package manager, upgrading your distribution to the latest version,
    or changing distributions.

    #{support_tier_message(tier: 3)}
  EOS
end

#check_linuxbrew_bottle_domainString?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



159
160
161
162
163
164
165
166
167
# File 'extend/os/linux/diagnostic.rb', line 159

def check_linuxbrew_bottle_domain
  return unless Homebrew::EnvConfig.bottle_domain.include?("linuxbrew")

  <<~EOS
    Your `$HOMEBREW_BOTTLE_DOMAIN` still contains "linuxbrew".
    You must unset it (or adjust it to not contain linuxbrew
    e.g. by using homebrew instead).
  EOS
end

#check_linuxbrew_coreString?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



148
149
150
151
152
153
154
155
156
# File 'extend/os/linux/diagnostic.rb', line 148

def check_linuxbrew_core
  return unless Homebrew::EnvConfig.no_install_from_api?
  return unless CoreTap.instance.linuxbrew_core?

  <<~EOS
    Your Linux core repository is still linuxbrew-core.
    You must `brew update` to update to homebrew-core.
  EOS
end

#check_supported_architectureString?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



83
84
85
86
87
88
89
90
91
92
93
# File 'extend/os/linux/diagnostic.rb', line 83

def check_supported_architecture
  return if ::Hardware::CPU.intel?
  return if Homebrew::EnvConfig.developer? && ENV["HOMEBREW_ARM64_TESTING"].present? && ::Hardware::CPU.arm?

  <<~EOS
    Your CPU architecture (#{::Hardware::CPU.arch}) is not supported. We only support
    x86_64 CPU architectures. You will be unable to use binary packages (bottles).

    #{support_tier_message(tier: 2)}
  EOS
end

#check_tmpdir_executableString?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'extend/os/linux/diagnostic.rb', line 52

def check_tmpdir_executable
  f = Tempfile.new(%w[homebrew_check_tmpdir_executable .sh], HOMEBREW_TEMP)
  f.write "#!/bin/sh\n"
  f.chmod 0700
  f.close
  return if system T.must(f.path)

  <<~EOS
    The directory #{HOMEBREW_TEMP} does not permit executing
    programs. It is likely mounted as "noexec". Please set `$HOMEBREW_TEMP`
    in your #{Utils::Shell.profile} to a different directory, for example:
      export HOMEBREW_TEMP=~/tmp
      echo 'export HOMEBREW_TEMP=~/tmp' >> #{Utils::Shell.profile}
  EOS
ensure
  f&.unlink
end

#check_tmpdir_sticky_bitString?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



38
39
40
41
42
43
44
45
46
47
48
49
# File 'extend/os/linux/diagnostic.rb', line 38

def check_tmpdir_sticky_bit
  message = super
  return if message.nil?

  message + <<~EOS
    If you don't have administrative privileges on this machine,
    create a directory and set the `$HOMEBREW_TEMP` environment variable,
    for example:
      install -d -m 1755 ~/tmp
      #{Utils::Shell.set_variable_in_profile("HOMEBREW_TEMP", "~/tmp")}
  EOS
end

#check_umask_not_zeroString?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



71
72
73
74
75
76
77
78
79
80
# File 'extend/os/linux/diagnostic.rb', line 71

def check_umask_not_zero
  return unless File.umask.zero?

  <<~EOS
    umask is currently set to 000. Directories created by Homebrew cannot
    be world-writable. This issue can be resolved by adding "umask 002" to
    your #{Utils::Shell.profile}:
      echo 'umask 002' >> #{Utils::Shell.profile}
  EOS
end

#fatal_preinstall_checksArray<String>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



20
21
22
23
24
25
26
# File 'extend/os/linux/diagnostic.rb', line 20

def fatal_preinstall_checks
  %w[
    check_access_directories
    check_linuxbrew_core
    check_linuxbrew_bottle_domain
  ].freeze
end

#supported_configuration_checksArray<String>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



29
30
31
32
33
34
35
# File 'extend/os/linux/diagnostic.rb', line 29

def supported_configuration_checks
  %w[
    check_glibc_minimum_version
    check_kernel_minimum_version
    check_supported_architecture
  ].freeze
end