Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uninstall: don't ignore deps even for developers #18784

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions Library/Homebrew/test/uninstall_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,15 @@
end

describe "::handle_unsatisfied_dependents" do
specify "when developer" 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
specify "when `ignore_dependencies` is false" do
expect do
described_class.handle_unsatisfied_dependents(kegs_by_rack)
end.to output(/Error/).to_stderr

expect(Homebrew).to have_failed
end

specify "when not developer and `ignore_dependencies` is true" do
specify "when `ignore_dependencies` is true" do
expect do
described_class.handle_unsatisfied_dependents(kegs_by_rack, ignore_dependencies: true)
end.not_to output.to_stderr
Expand Down
37 changes: 10 additions & 27 deletions Library/Homebrew/uninstall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,7 @@ def self.handle_unsatisfied_dependents(kegs_by_rack, casks: [], ignore_dependenc
def self.check_for_dependents(kegs, casks: [], named_args: [])
return false unless (result = InstalledDependents.find_some_installed_dependents(kegs, casks:))

if Homebrew::EnvConfig.developer?
DeveloperDependentsMessage.new(*result, named_args:).output
else
NondeveloperDependentsMessage.new(*result, named_args:).output
end

DependentsMessage.new(*result, named_args:).output
true
end

Expand All @@ -124,6 +119,15 @@ def initialize(requireds, dependents, named_args: [])
@named_args = named_args
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

def sample_command
Expand All @@ -136,27 +140,6 @@ def are_required_by_deps
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)
Formulary.from_rack(rack).unpin
rescue
Expand Down
Loading