Class: Caveats Private
- Extended by:
- Forwardable
- Defined in:
- caveats.rb,
sorbet/rbi/dsl/caveats.rbi
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
A formula's caveats.
Instance Attribute Summary collapse
- #formula ⇒ Formula readonly private
Instance Method Summary collapse
- #caveats ⇒ String private
- #completions_and_elisp ⇒ Array<String> private
- #empty? ⇒ Boolean private
- #initialize(formula, shadowed_path: true) ⇒ void constructor private
- #keg_only_text(skip_reason: false) ⇒ String? private
- #shadowed_path_executables ⇒ Array<Array<(String, Pathname)>> private
- #shadowed_path_text ⇒ String? private
Constructor Details
#initialize(formula, shadowed_path: 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.
17 18 19 20 21 22 23 |
# File 'caveats.rb', line 17 def initialize(formula, shadowed_path: true) @formula = formula @shadowed_path = shadowed_path @caveats = T.let(nil, T.nilable(String)) @completions_and_elisp = T.let(nil, T.nilable(T::Array[String])) @shadowed_executables = T.let(nil, T.nilable(T::Array[[String, Pathname]])) end |
Instance Attribute Details
#formula ⇒ Formula (readonly)
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.
14 15 16 |
# File 'caveats.rb', line 14 def formula @formula end |
Instance Method Details
#caveats ⇒ 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.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'caveats.rb', line 26 def caveats @caveats ||= begin caveats = [] build = formula.build begin formula.build = Tab.for_formula(formula) string = formula.caveats.to_s caveats << "#{string.chomp}\n" unless string.empty? ensure formula.build = build end caveats << keg_only_text caveats << shadowed_path_text if @shadowed_path caveats << service_caveats caveats.compact.join("\n") end end |
#completions_and_elisp ⇒ Array<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.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'caveats.rb', line 52 def completions_and_elisp @completions_and_elisp ||= begin valid_shells = [:bash, :zsh, :fish, :pwsh].freeze current_shell = Utils::Shell.preferred || Utils::Shell.parent shells = if current_shell.present? && (shell_sym = current_shell.to_sym) && valid_shells.include?(shell_sym) [shell_sym] else valid_shells end completions_and_elisp = shells.map do |shell| function_completion_caveats(shell) end completions_and_elisp << elisp_caveats completions_and_elisp.compact end end |
#empty? ⇒ Boolean
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.
45 46 47 |
# File 'caveats.rb', line 45 def empty? caveats.blank? && completions_and_elisp.blank? end |
#keg_only_text(skip_reason: false) ⇒ 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.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'caveats.rb', line 72 def keg_only_text(skip_reason: false) return unless formula.keg_only? return if formula.linked? s = if skip_reason "" else <<~EOS #{formula.name} is keg-only, which means it was not symlinked into #{HOMEBREW_PREFIX}, because #{formula.keg_only_reason.to_s.chomp}. EOS end.dup if formula.bin.directory? || formula.sbin.directory? s << <<~EOS If you need to have #{formula.name} first in your PATH, run: EOS s << " #{Utils::Shell.prepend_path_in_profile(formula.opt_bin.to_s)}\n" if formula.bin.directory? s << " #{Utils::Shell.prepend_path_in_profile(formula.opt_sbin.to_s)}\n" if formula.sbin.directory? end if formula.lib.directory? || formula.include.directory? s << <<~EOS For compilers to find #{formula.name} you may need to set: EOS s << " #{Utils::Shell.export_value("LDFLAGS", "-L#{formula.opt_lib}")}\n" if formula.lib.directory? s << " #{Utils::Shell.export_value("CPPFLAGS", "-I#{formula.opt_include}")}\n" if formula.include.directory? if which("pkgconf", ORIGINAL_PATHS) && ((formula.lib/"pkgconfig").directory? || (formula.share/"pkgconfig").directory?) s << <<~EOS For pkgconf to find #{formula.name} you may need to set: EOS if (formula.lib/"pkgconfig").directory? s << " #{Utils::Shell.export_value("PKG_CONFIG_PATH", "#{formula.opt_lib}/pkgconfig")}\n" end if (formula.share/"pkgconfig").directory? s << " #{Utils::Shell.export_value("PKG_CONFIG_PATH", "#{formula.opt_share}/pkgconfig")}\n" end end if which("cmake", ORIGINAL_PATHS) && ((formula.lib/"cmake").directory? || (formula.share/"cmake").directory?) s << <<~EOS For cmake to find #{formula.name} you may need to set: #{Utils::Shell.export_value("CMAKE_PREFIX_PATH", formula.opt_prefix.to_s)} EOS end end s << "\n" unless s.end_with?("\n") s end |
#shadowed_path_executables ⇒ Array<Array<(String, Pathname)>>
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.
134 135 136 137 138 139 140 141 |
# File 'caveats.rb', line 134 def shadowed_path_executables return [] if Homebrew::EnvConfig.no_path_shadow_check? return [] unless formula.any_version_installed? shadowed = shadowed_executables shadowed = shadowed.select { |_, shadower| sibling_keg_name(shadower) } if formula.keg_only? && !formula.linked? shadowed.sort_by(&:first) end |
#shadowed_path_text ⇒ 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.
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 169 170 171 172 173 |
# File 'caveats.rb', line 144 def shadowed_path_text shadowed = shadowed_path_executables return if shadowed.empty? sibling, external = shadowed.partition { |_, shadower| sibling_keg_name(shadower) } blocks = [] if external.any? blocks << <<~EOS #{shadowed_columns(external)} Running these by name will not invoke the version provided by Homebrew because the shadowing commands come earlier in your PATH. EOS end if sibling.any? blocks << <<~EOS #{shadowed_columns(sibling)} Running these by name will not invoke the version provided by this formula. Run `brew link #{formula.name}` to switch the active version to this keg. EOS end s = blocks.join("\n").dup unless Homebrew::EnvConfig.no_env_hints? s << "Disable this behaviour by setting `HOMEBREW_NO_PATH_SHADOW_CHECK=1`.\n" s << "Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).\n" end s end |