mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
uninstall: don't ignore deps even for developers
This was discussed a while back on Slack. The idea behind this is that ignoring dependencies during `brew uninstall` makes it too easy to break things, even for developers. Those who know what they are doing can, and IMO should, always use the `--ignore-dependencies` flag.
This commit is contained in:
parent
cc0b5d6d05
commit
f2cb33011a
@ -47,17 +47,7 @@ RSpec.describe Homebrew::Uninstall do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "::handle_unsatisfied_dependents" do
|
describe "::handle_unsatisfied_dependents" do
|
||||||
specify "when developer" do
|
specify "when `ignore_dependencies` is false" do
|
||||||
ENV["HOMEBREW_DEVELOPER"] = "1"
|
|
||||||
|
|
||||||
expect do
|
|
||||||
described_class.handle_unsatisfied_dependents(kegs_by_rack)
|
|
||||||
end.to output(/Warning/).to_stderr
|
|
||||||
|
|
||||||
expect(Homebrew).not_to have_failed
|
|
||||||
end
|
|
||||||
|
|
||||||
specify "when not developer" do
|
|
||||||
expect do
|
expect do
|
||||||
described_class.handle_unsatisfied_dependents(kegs_by_rack)
|
described_class.handle_unsatisfied_dependents(kegs_by_rack)
|
||||||
end.to output(/Error/).to_stderr
|
end.to output(/Error/).to_stderr
|
||||||
@ -65,7 +55,7 @@ RSpec.describe Homebrew::Uninstall do
|
|||||||
expect(Homebrew).to have_failed
|
expect(Homebrew).to have_failed
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "when not developer and `ignore_dependencies` is true" do
|
specify "when `ignore_dependencies` is true" do
|
||||||
expect do
|
expect do
|
||||||
described_class.handle_unsatisfied_dependents(kegs_by_rack, ignore_dependencies: true)
|
described_class.handle_unsatisfied_dependents(kegs_by_rack, ignore_dependencies: true)
|
||||||
end.not_to output.to_stderr
|
end.not_to output.to_stderr
|
||||||
|
@ -106,12 +106,7 @@ module Homebrew
|
|||||||
def self.check_for_dependents(kegs, casks: [], named_args: [])
|
def self.check_for_dependents(kegs, casks: [], named_args: [])
|
||||||
return false unless (result = InstalledDependents.find_some_installed_dependents(kegs, casks:))
|
return false unless (result = InstalledDependents.find_some_installed_dependents(kegs, casks:))
|
||||||
|
|
||||||
if Homebrew::EnvConfig.developer?
|
DependentsMessage.new(*result, named_args:).output
|
||||||
DeveloperDependentsMessage.new(*result, named_args:).output
|
|
||||||
else
|
|
||||||
NondeveloperDependentsMessage.new(*result, named_args:).output
|
|
||||||
end
|
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -124,6 +119,15 @@ module Homebrew
|
|||||||
@named_args = named_args
|
@named_args = named_args
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def output
|
||||||
|
ofail <<~EOS
|
||||||
|
Refusing to uninstall #{reqs.to_sentence}
|
||||||
|
because #{(reqs.count == 1) ? "it" : "they"} #{are_required_by_deps}.
|
||||||
|
You can override this and force removal with:
|
||||||
|
#{sample_command}
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def sample_command
|
def sample_command
|
||||||
@ -136,27 +140,6 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class DeveloperDependentsMessage < DependentsMessage
|
|
||||||
def output
|
|
||||||
opoo <<~EOS
|
|
||||||
#{reqs.to_sentence} #{are_required_by_deps}.
|
|
||||||
You can silence this warning with:
|
|
||||||
#{sample_command}
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class NondeveloperDependentsMessage < DependentsMessage
|
|
||||||
def output
|
|
||||||
ofail <<~EOS
|
|
||||||
Refusing to uninstall #{reqs.to_sentence}
|
|
||||||
because #{(reqs.count == 1) ? "it" : "they"} #{are_required_by_deps}.
|
|
||||||
You can override this and force removal with:
|
|
||||||
#{sample_command}
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.rm_pin(rack)
|
def self.rm_pin(rack)
|
||||||
Formulary.from_rack(rack).unpin
|
Formulary.from_rack(rack).unpin
|
||||||
rescue
|
rescue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user