Skip to content
Open
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
8 changes: 4 additions & 4 deletions Library/Homebrew/bundle/brew_services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ def started?(name)
end

def started_services
@started_services ||= begin
if !Homebrew::Services::System.launchctl? && !Homebrew::Services::System.systemctl?
odie Homebrew::Services::System::MISSING_DAEMON_MANAGER_EXCEPTION_MESSAGE
end
@started_services ||= if !Homebrew::Services::System.launchctl? && !Homebrew::Services::System.systemctl?
opoo "Skipping `brew services list` due to missing launchctl/systemctl"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I know this is annoying:

  • a missing launchctl basically never happens
  • a missing systemctl is very common in some Linux environments

As a result, I think this should be OS-specific behaviour where we odie on macOS and opoo on Linux.

[]
else
states_to_skip = %w[stopped none]

services_list = JSON.parse(Utils.safe_popen_read(HOMEBREW_BREW_FILE, "services", "list", "--json"))
Expand Down
7 changes: 2 additions & 5 deletions Library/Homebrew/test/bundle/brew_services_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@
expect(described_class.started_services).to eq([])
end

it "exits with error when no daemon manager is available" do
it "returns empty array when no daemon manager is available" do
allow(Homebrew::Services::System).to receive_messages(launchctl?: false, systemctl?: false)
expect do
described_class.started_services
end.to raise_error(SystemExit)
.and output(/supported only on macOS or Linux/).to_stderr
expect(described_class.started_services).to eq([])
end
end

Expand Down
Loading