Skip to content

services: start/status reject the keg name, and a missing working_dir fails with no diagnostic #796

Description

@rustytrees

Hit both of these trying to start a service on a real install. They compound: the first stops you finding the service, the second stops it running once you do, and neither produces a useful diagnostic.

$ malt services start mosquitto
error: ServiceNotFound

1. services start <keg> cannot find a service that services list shows

Registration stores the launchd label in name and the formula in keg_name (supervisor.zig:230):

name = com.malt.mosquitto    keg_name = mosquitto

but the lifecycle lookup queries name only, so the keg name misses. Every other verb takes the formula name — install mosquitto, uninstall mosquitto, link mosquitto — so the one place that requires the label is the one place a user has no reason to expect it. services list does print the label, but nothing signals that it is the required key.

services status mosquitto fails the same way, via hasService.

2. A service whose working_dir does not exist cannot start, silently

With the label, it registers and bootstraps — then dies:

$ malt services start com.malt.mosquitto
  ✓ services start: com.malt.mosquitto
$ malt services list
com.malt.mosquitto	errored	manual	mosquitto
$ launchctl list | grep mosquitto
-	78	com.malt.mosquitto

Status 78 is EX_CONFIG. launchd refuses the spawn because WorkingDirectory does not exist — and it refuses it before exec, so StandardErrorPath is never created either. There is no log to read, and nothing anywhere names the offending path. /opt/malt/var/log/ was empty.

The plist referenced two paths that did not exist:

  • WorkingDirectory/opt/malt/var/mosquitto ← the EX_CONFIG cause
  • -c config → /opt/malt/etc/mosquitto/mosquitto.conf

cli/install.zig already pre-creates {prefix}/var/log for exactly this reason; working_dir is the half that got missed, and nothing else in the install path creates it.

mosquitto is a plain example rather than an exotic one: post_install_defined: false, its install block is a bare cmake install, and 2.1.2 ships only .example files — so neither var/mosquitto nor mosquitto.conf is ever created by anyone. (Its caveats claim "installed with a default configuration file", which is inaccurate for this version; that part is upstream's, not malt's.)

Creating the two paths by hand was enough to get it running:

$ malt services list
com.malt.mosquitto	running	manual	mosquitto
$ launchctl list | grep mosquitto
65961	0	com.malt.mosquitto

Scope

Fix for both in the PR that follows. Worth deciding separately whether malt should also seed a missing config file named by a service.run argument, or leave that to the user — I did not do that, since inventing config content is a different kind of decision from creating a directory the plist declares.

Reproduced on 0.22 code; the name/keg_name split and the missing working_dir creation are both present on current main.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions