Module: OS::Mac::Diagnostic::Checks Private

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

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.

Instance Method Summary collapse

Instance Method Details

#build_from_source_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:



103
104
105
106
107
108
109
# File 'extend/os/mac/diagnostic.rb', line 103

def build_from_source_checks
  %w[
    check_for_installed_developer_tools
    check_xcode_up_to_date
    check_clt_up_to_date
  ].freeze
end

#check_cask_quarantine_support::Homebrew::Diagnostic::Finding?

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.



558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
# File 'extend/os/mac/diagnostic.rb', line 558

def check_cask_quarantine_support
  status, check_output = ::Cask::Quarantine.check_quarantine_support

  messages = case status
  when :quarantine_available
    [nil, nil]
  when :xattr_broken
    ["No Cask quarantine support available: there's no working version of `xattr` on this system.", nil]
  when :no_swift
    ["No Cask quarantine support available: there's no available version of `swift` on this system.", nil]
  when :swift_broken_clt
    ["No Cask quarantine support available: Swift is not working due to missing Command Line Tools.", MacOS::CLT.installation_then_reinstall_instructions]
  when :swift_compilation_failed
    msg = <<~EOS
      No Cask quarantine support available: Swift compilation failed.
      This is usually due to a broken or incompatible Command Line Tools installation.
    EOS
    [msg, MacOS::CLT.installation_then_reinstall_instructions]
  when :swift_runtime_error
    msg = <<~EOS
      No Cask quarantine support available: Swift runtime error.
      Your Command Line Tools installation may be broken or incomplete.
    EOS
    [msg, MacOS::CLT.installation_then_reinstall_instructions]
  when :swift_not_executable
    msg = <<~EOS
      No Cask quarantine support available: Swift is not executable.
      Your Command Line Tools installation may be incomplete.
    EOS
    [msg, MacOS::CLT.installation_then_reinstall_instructions]
  when :swift_unexpected_error
    msg = <<~EOS
      No Cask quarantine support available: Swift returned an unexpected error:
      #{check_output}
    EOS
    [msg, nil]
  else
    msg = <<~EOS
      No Cask quarantine support available: unknown reason: #{status.inspect}:
      #{check_output}
    EOS
    [msg, nil]
  end

  message, remediation = messages
  return if message.blank?

  ::Homebrew::Diagnostic::Finding.new(message, remediation:)
end

#check_cask_software_versions::Homebrew::Diagnostic::Finding?

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.



525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
# File 'extend/os/mac/diagnostic.rb', line 525

def check_cask_software_versions
  super
  add_info "macOS", MacOS.full_version
  add_info "SIP", begin
    csrutil = "/usr/bin/csrutil"
    if File.executable?(csrutil)
      Open3.capture2(csrutil, "status")
           .first
           .gsub("This is an unsupported configuration, likely to break in " \
                 "the future and leave your machine in an unknown state.", "")
           .gsub("System Integrity Protection status: ", "")
           .delete("\t.")
           .capitalize
           .strip
    else
      "N/A"
    end
  end

  nil
end

#check_clt_minimum_version::Homebrew::Diagnostic::Finding?

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.



244
245
246
247
248
249
250
251
252
253
# File 'extend/os/mac/diagnostic.rb', line 244

def check_clt_minimum_version
  return unless MacOS::CLT.below_minimum_version?

  ::Homebrew::Diagnostic::Finding.new(
    <<~EOS,
      Your Command Line Tools are too outdated.
    EOS
    remediation: MacOS::CLT.update_instructions,
  )
end

#check_clt_up_to_date::Homebrew::Diagnostic::Finding?

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.



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'extend/os/mac/diagnostic.rb', line 206

def check_clt_up_to_date
  return unless MacOS::CLT.outdated?

  # avoid duplicate very similar messages
  return if MacOS::CLT.below_minimum_version?

  # CI images are going to end up outdated so don't complain when
  # `brew test-bot` runs `brew doctor` in the CI for the Homebrew/brew
  # repository. This only needs to support whatever CI providers
  # Homebrew/brew is currently using.
  return if GitHub::Actions.env_set?

  ::Homebrew::Diagnostic::Finding.new(
    "A newer Command Line Tools release is available.",
    tier:        2,
    remediation: MacOS::CLT.update_instructions,
  )
end

#check_filesystem_case_sensitive::Homebrew::Diagnostic::Finding?

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.



341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# File 'extend/os/mac/diagnostic.rb', line 341

def check_filesystem_case_sensitive
  dirs_to_check = [
    HOMEBREW_PREFIX,
    HOMEBREW_REPOSITORY,
    HOMEBREW_CELLAR,
    HOMEBREW_TEMP,
  ]
  case_sensitive_dirs = dirs_to_check.select do |dir|
    # We select the dir as being case-sensitive if either the UPCASED or the
    # downcased variant is missing.
    # Of course, on a case-insensitive fs, both exist because the os reports so.
    # In the rare situation when the user has indeed a downcased and an upcased
    # dir (e.g. /TMP and /tmp) this check falsely thinks it is case-insensitive
    # but we don't care because: 1. there is more than one dir checked, 2. the
    # check is not vital and 3. we would have to touch files otherwise.
    upcased = ::Pathname.new(dir.to_s.upcase)
    downcased = ::Pathname.new(dir.to_s.downcase)
    dir.exist? && !(upcased.exist? && downcased.exist?)
  end
  return if case_sensitive_dirs.empty?

  volumes = Volumes.new
  case_sensitive_vols = case_sensitive_dirs.map do |case_sensitive_dir|
    volumes.get_mounts(case_sensitive_dir)
  end
  case_sensitive_vols.uniq!

  ::Homebrew::Diagnostic::Finding.new(
    <<~EOS,
      The filesystem on #{case_sensitive_vols.join(",")} appears to be case-sensitive.
      The default macOS filesystem is case-insensitive. Please report any apparent problems.
    EOS
  )
end

#check_for_gettext::Homebrew::Diagnostic::Finding?

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.



377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# File 'extend/os/mac/diagnostic.rb', line 377

def check_for_gettext
  find_relative_paths("lib/libgettextlib.dylib",
                      "lib/libintl.dylib",
                      "include/libintl.h")
  return if @found.empty?

  # Our gettext formula will be caught by check_linked_keg_only_brews
  gettext = begin
    Formulary.factory("gettext")
  rescue
    nil
  end

  if gettext&.linked_keg&.directory?
    allowlist = ["#{HOMEBREW_CELLAR}/gettext"]
    if ::Hardware::CPU.physical_cpu_arm64?
      allowlist += %W[
        #{HOMEBREW_MACOS_ARM_DEFAULT_PREFIX}/Cellar/gettext
        #{HOMEBREW_DEFAULT_PREFIX}/Cellar/gettext
      ]
    end

    return if @found.all? do |path|
      realpath = ::Pathname.new(path).realpath.to_s
      realpath.start_with?(*allowlist)
    end
  end

  ::Homebrew::Diagnostic::Finding.new(
    <<~EOS,
    remediation: append_indented_list(@found, <<~EOS),
      Consider removing these files:
    EOS
  )
end

#check_for_iconv::Homebrew::Diagnostic::Finding?

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.



418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
# File 'extend/os/mac/diagnostic.rb', line 418

def check_for_iconv
  find_relative_paths("lib/libiconv.dylib", "include/iconv.h")
  return if @found.empty?

  libiconv = begin
    Formulary.factory("libiconv")
  rescue
    nil
  end
  if libiconv&.linked_keg&.directory?
    unless libiconv&.keg_only?
      ::Homebrew::Diagnostic::Finding.new(
        <<~EOS,
          A libiconv formula is installed and linked.
          This will break stuff. For serious. Unlink it.
        EOS
      )
    end
  else
    ::Homebrew::Diagnostic::Finding.new(
      <<~EOS,
      remediation: append_indented_list(@found, <<~EOS),
        Consider removing these files:
      EOS
    )
  end
end

#check_for_multiple_volumes::Homebrew::Diagnostic::Finding?

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.



454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
# File 'extend/os/mac/diagnostic.rb', line 454

def check_for_multiple_volumes
  return unless HOMEBREW_CELLAR.exist?

  volumes = Volumes.new

  # Find the volumes for the TMP folder & HOMEBREW_CELLAR
  real_cellar = HOMEBREW_CELLAR.realpath
  where_cellar = volumes.index_of real_cellar

  begin
    tmp = ::Pathname.new(Dir.mktmpdir("doctor", HOMEBREW_TEMP))
    begin
      real_tmp = tmp.realpath.parent
      where_tmp = volumes.index_of real_tmp
    ensure
      Dir.delete tmp.to_s
    end
  rescue
    return
  end

  return if where_cellar == where_tmp

  ::Homebrew::Diagnostic::Finding.new(
    <<~EOS,
    tier:        2,
    remediation: <<~EOS,
      You should set the `$HOMEBREW_TEMP` environment variable to a suitable
      directory on the same volume as your Cellar.
    EOS
  )
end

#check_for_non_prefixed_findutils::Homebrew::Diagnostic::Finding?

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.



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

def check_for_non_prefixed_findutils
  findutils = ::Formula["findutils"]
  return unless findutils.any_version_installed?

  gnubin = %W[#{findutils.opt_libexec}/gnubin #{findutils.libexec}/gnubin]
  default_names = Tab.for_name("findutils").with? "default-names"
  return if !default_names && !paths.intersect?(gnubin)

  ::Homebrew::Diagnostic::Finding.new(
    <<~EOS,
      Putting non-prefixed findutils in your path can cause python builds to fail.
    EOS
  )
rescue FormulaUnavailableError
  nil
end

#check_for_unsupported_macos::Homebrew::Diagnostic::Finding?

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.



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'extend/os/mac/diagnostic.rb', line 130

def check_for_unsupported_macos
  return if Homebrew::EnvConfig.developer?
  return if ENV["HOMEBREW_INTEGRATION_TEST"]

  tier = 2
  who = +"We"
  version = MacOS.version
  what = if OS::Mac.version.outdated_release?
    tier = 3
    who << " (and Apple)"
    "old version."
  elsif ::Hardware::CPU.intel?
    tier = 3
    version = "on Intel x86_64"
    <<~EOS
      platform (as-of September 2026, announced August 2025).

      Apple have dropped Intel x86_64 support in macOS Golden Gate (27).
      GitHub Actions are dropping macOS Intel x86_64 runners in 2027.
      Homebrew is a non-profit project run entirely by volunteers, not employees.
      If the biggest companies in the world cannot support macOS Intel x86_64
      any longer, sadly neither can we.
    EOS
  elsif OS::Mac.version.prerelease?
    "pre-release version."
  end
  return if what.blank?

  who.freeze

  ::Homebrew::Diagnostic::Finding.new(
    <<~EOS,
      You are using macOS #{version}.
      #{who} do not provide support for this #{what.chomp}
    EOS
    tier:,
    remediation: macos_bottle_remediation(MacOS.version, intel: ::Hardware::CPU.intel?),
  )
end

#check_if_supported_sdk_available::Homebrew::Diagnostic::Finding?

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.



492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
# File 'extend/os/mac/diagnostic.rb', line 492

def check_if_supported_sdk_available
  return unless ::DevelopmentTools.installed?
  return if MacOS.sdk

  locator = MacOS.sdk_locator

  source = if locator.source == :clt
    return if MacOS::CLT.below_minimum_version? # Handled by other diagnostics.

    update_instructions = MacOS::CLT.update_instructions
    "Command Line Tools (CLT)"
  else
    return if MacOS::Xcode.below_minimum_version? # Handled by other diagnostics.

    update_instructions = MacOS::Xcode.update_instructions
    "Xcode"
  end

  ::Homebrew::Diagnostic::Finding.new(
    <<~EOS,
    remediation: ::Homebrew::Diagnostic::Finding::Remediation.new(
      text: <<~EOS,
        Please update your #{source} or delete it if no updates are available.
        #{update_instructions}
      EOS
    ),
  )
end

#check_if_xcode_needs_clt_installed::Homebrew::Diagnostic::Finding?

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.



256
257
258
259
260
261
262
263
264
265
# File 'extend/os/mac/diagnostic.rb', line 256

def check_if_xcode_needs_clt_installed
  return unless MacOS::Xcode.needs_clt_installed?

  ::Homebrew::Diagnostic::Finding.new(
    <<~EOS,
      Xcode alone is not sufficient on #{MacOS.version.pretty_name}.
    EOS
    remediation: ::DevelopmentTools.installation_instructions,
  )
end

#check_pkgconf_macos_sdk_mismatch::Homebrew::Diagnostic::Finding?

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.



548
549
550
551
552
553
554
555
# File 'extend/os/mac/diagnostic.rb', line 548

def check_pkgconf_macos_sdk_mismatch
  mismatch = Homebrew::Pkgconf.macos_sdk_mismatch
  return unless mismatch

  ::Homebrew::Diagnostic::Finding.new(
    Homebrew::Pkgconf.mismatch_warning_message(mismatch),
  )
end

#check_xcode_license_approved::Homebrew::Diagnostic::Finding?

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.



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'extend/os/mac/diagnostic.rb', line 320

def check_xcode_license_approved
  # If the user installs Xcode-only, they have to approve the
  # license or no "xc*" tool will work.
  return unless Utils.popen_read_text("/usr/bin/xcrun", "--find", "clang", err: :out).include?("license")
  return if $CHILD_STATUS.success?

  commands = ["sudo xcodebuild -license"]
  ::Homebrew::Diagnostic::Finding.new(
    <<~EOS,
    remediation: ::Homebrew::Diagnostic::Finding::Remediation.new(
      text:     append_indented_list(commands, <<~EOS),
        Agree to the license by opening Xcode.app or running:
      EOS
      commands:,
    ),
  )
end

#check_xcode_minimum_version::Homebrew::Diagnostic::Finding?

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.



226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'extend/os/mac/diagnostic.rb', line 226

def check_xcode_minimum_version
  return unless MacOS::Xcode.below_minimum_version?

  xcode = MacOS::Xcode.version.to_s
  xcode += " => #{MacOS::Xcode.prefix}" unless MacOS::Xcode.default_prefix?

  ::Homebrew::Diagnostic::Finding.new(
    <<~EOS,
    remediation: <<~EOS,
      Please update to Xcode #{MacOS::Xcode.latest_version} (or delete it).
      #{MacOS::Xcode.update_instructions}
    EOS
  )
end

#check_xcode_prefix::Homebrew::Diagnostic::Finding?

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.



268
269
270
271
272
273
274
275
276
277
278
279
# File 'extend/os/mac/diagnostic.rb', line 268

def check_xcode_prefix
  prefix = MacOS::Xcode.prefix
  return if prefix.nil?
  return unless prefix.to_s.include?(" ")

  ::Homebrew::Diagnostic::Finding.new(
    <<~EOS,
      Xcode is installed to a directory with a space in the name.
      This will cause some formulae to fail to build.
    EOS
  )
end

#check_xcode_prefix_exists::Homebrew::Diagnostic::Finding?

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.



282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'extend/os/mac/diagnostic.rb', line 282

def check_xcode_prefix_exists
  prefix = MacOS::Xcode.prefix
  return if prefix.nil? || prefix.exist?

  ::Homebrew::Diagnostic::Finding.new(
    <<~EOS,
    remediation: <<~EOS,
      You may need to `xcode-select` the proper path if you have moved Xcode.
    EOS
  )
end

#check_xcode_select_path::Homebrew::Diagnostic::Finding?

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.



298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'extend/os/mac/diagnostic.rb', line 298

def check_xcode_select_path
  return if MacOS::CLT.installed?
  return unless MacOS::Xcode.installed?
  return if File.file?("#{MacOS.active_developer_dir}/usr/bin/xcodebuild")

  path = MacOS::Xcode.bundle_path
  path = "/Developer" if path.nil? || !path.directory?
  commands = ["sudo xcode-select --switch #{path}"]
  ::Homebrew::Diagnostic::Finding.new(
    <<~EOS,
    remediation: ::Homebrew::Diagnostic::Finding::Remediation.new(
      text:     append_indented_list(commands, <<~EOS),
        You should change it to the correct path:
      EOS
      commands:,
    ),
  )
end

#check_xcode_up_to_date::Homebrew::Diagnostic::Finding?

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.



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'extend/os/mac/diagnostic.rb', line 171

def check_xcode_up_to_date
  return unless MacOS::Xcode.outdated?

  # avoid duplicate very similar messages
  return if MacOS::Xcode.below_minimum_version?

  # CI images are going to end up outdated so don't complain when
  # `brew test-bot` runs `brew doctor` in the CI for the Homebrew/brew
  # repository. This only needs to support whatever CI providers
  # Homebrew/brew is currently using.
  return if GitHub::Actions.env_set?

  remediation = <<~EOS
    Please update to Xcode #{MacOS::Xcode.latest_version} (or delete it).
    #{MacOS::Xcode.update_instructions}
  EOS

  if OS::Mac.version.prerelease?
    current_path = Utils.popen_read("/usr/bin/xcode-select", "-p")
    remediation += <<~EOS
      If #{MacOS::Xcode.latest_version} is installed, you may need to:
        sudo xcode-select --switch /Applications/Xcode.app
      Current developer directory is:
        #{current_path}
    EOS
  end

  ::Homebrew::Diagnostic::Finding.new(
    "Your Xcode (#{MacOS::Xcode.version}) is outdated.",
    tier:        2,
    remediation:,
  )
end

#fatal_build_from_source_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:



75
76
77
78
79
80
81
82
83
84
# File 'extend/os/mac/diagnostic.rb', line 75

def fatal_build_from_source_checks
  %w[
    check_for_installed_developer_tools
    check_xcode_license_approved
    check_xcode_minimum_version
    check_clt_minimum_version
    check_if_xcode_needs_clt_installed
    check_if_supported_sdk_available
  ].freeze
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:



62
63
64
65
66
67
68
69
70
71
72
# File 'extend/os/mac/diagnostic.rb', line 62

def fatal_preinstall_checks
  checks = %w[
    check_access_directories
  ]

  # We need the developer tools for `codesign` on Intel:
  # https://github.com/Homebrew/brew/issues/23418
  checks << "check_for_installed_developer_tools" unless ::Hardware::CPU.arm?

  checks.freeze
end

#fatal_setup_build_environment_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:



87
88
89
90
91
92
93
# File 'extend/os/mac/diagnostic.rb', line 87

def fatal_setup_build_environment_checks
  %w[
    check_xcode_minimum_version
    check_clt_minimum_version
    check_if_supported_sdk_available
  ].freeze
end

#initialize(verbose: true) ⇒ void

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.

Parameters:

  • verbose (Boolean) (defaults to: true)


56
57
58
59
# File 'extend/os/mac/diagnostic.rb', line 56

def initialize(verbose: true)
  super
  @found = T.let([], T::Array[String])
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:



96
97
98
99
100
# File 'extend/os/mac/diagnostic.rb', line 96

def supported_configuration_checks
  %w[
    check_for_unsupported_macos
  ].freeze
end