Class: Homebrew::Cmd::Reinstall

Inherits:
AbstractCommand show all
Defined in:
cmd/reinstall.rb

Instance Attribute Summary

Attributes inherited from AbstractCommand

#args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, #initialize, parser

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#runvoid

This method returns an undefined value.



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'cmd/reinstall.rb', line 110

def run
  formulae, casks = T.cast(
    args.named.to_formulae_and_casks(method: :resolve).partition { _1.is_a?(Formula) },
    [T::Array[Formula], T::Array[Cask::Cask]],
  )

  if args.build_from_source?
    unless DevelopmentTools.installed?
      raise BuildFlagsError.new(["--build-from-source"], bottled: formulae.all?(&:bottled?))
    end

    unless Homebrew::EnvConfig.developer?
      opoo "building from source is not supported!"
      puts "You're on your own. Failures are expected so don't create any issues, please!"
    end
  end

  Install.perform_preinstall_checks

  formulae.each do |formula|
    if formula.pinned?
      onoe "#{formula.full_name} is pinned. You must unpin it to reinstall."
      next
    end
    Migrator.migrate_if_needed(formula, force: args.force?)
    Homebrew.reinstall_formula(
      formula,
      flags:                      args.flags_only,
      installed_on_request:       args.named.present?,
      force_bottle:               args.force_bottle?,
      build_from_source_formulae: args.build_from_source_formulae,
      interactive:                args.interactive?,
      keep_tmp:                   args.keep_tmp?,
      debug_symbols:              args.debug_symbols?,
      force:                      args.force?,
      debug:                      args.debug?,
      quiet:                      args.quiet?,
      verbose:                    args.verbose?,
      git:                        args.git?,
    )
    Cleanup.install_formula_clean!(formula)
  end

  Upgrade.check_installed_dependents(
    formulae,
    flags:                      args.flags_only,
    installed_on_request:       args.named.present?,
    force_bottle:               args.force_bottle?,
    build_from_source_formulae: args.build_from_source_formulae,
    interactive:                args.interactive?,
    keep_tmp:                   args.keep_tmp?,
    debug_symbols:              args.debug_symbols?,
    force:                      args.force?,
    debug:                      args.debug?,
    quiet:                      args.quiet?,
    verbose:                    args.verbose?,
  )

  if casks.any?
    Cask::Reinstall.reinstall_casks(
      *casks,
      binaries:       args.binaries?,
      verbose:        args.verbose?,
      force:          args.force?,
      require_sha:    args.require_sha?,
      skip_cask_deps: args.skip_cask_deps?,
      quarantine:     args.quarantine?,
      zap:            args.zap?,
    )
  end

  Cleanup.periodic_clean!

  Homebrew.messages.display_messages(display_times: args.display_times?)
end