Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Status and doctor

Checking an install

drawbar status reports how drawbar is set up on this machine, and changes nothing while it does:

$ drawbar status
drawbar 0.1.0

install
  /home/acme/.local/bin/git: drawbar, links to /home/acme/.local/opt/drawbar/drawbar
  /home/acme/.local/bin/drawbar: drawbar, links to /home/acme/.local/opt/drawbar/drawbar
  /home/acme/.local/opt/drawbar/drawbar: present

real git
  /home/acme/.local/opt/git-2.56.1/bin/git: git 2.56.1

resolve cache
  /home/acme/.cache/drawbar/real-git.cache: fresh: /home/acme/.local/opt/git-2.56.1/bin/git (git 2.56.1)

config
  /home/acme/.config/drawbar/config.toml: absent, using the defaults
  fsmonitor.mode = "auto"
  fsmonitor.min_tracked_files = 3000
  fsmonitor.include = []
  fsmonitor.exclude = []
  lease.timeout_secs = 120
  lease.suppress_auto_gc = true
  drawbard.coalesce_ttl_secs = 0

fsmonitor
  /home/acme/src/widgets, 48210 tracked files
  gets core.fsmonitor: its tracked files reach fsmonitor.min_tracked_files

drawbard
  /run/user/1000/drawbar/drawbard.sock: running, protocol 2
  /home/acme/.config/systemd/user/drawbard.service: installed

Each section of the report answers one question:

  • install says whether ~/.local/bin/git and ~/.local/bin/drawbar run drawbar, and whether the installed copy is in place.
  • real git names the git the shim runs and its version, found the way the shim finds it, or says why no git resolves.
  • resolve cache says whether the next git call can use the cached real-git path (fresh) or has to probe the candidates again (missing or stale).
  • config names the file it read and lists the settings in force. When the shim would ignore the file, the report gives the reason and lists the defaults in its place.
  • environment lists the variables that change the shim, such as DRAWBAR_REAL_GIT and DRAWBAR_LEASE_WAIT, and appears only when one is set.
  • fsmonitor names the repository in the current directory and its tracked-file count, and says whether the shim adds core.fsmonitor there and why.
  • drawbard names drawbard’s socket and says whether a daemon answers there and in which protocol, and whether drawbard.service is installed, is a file drawbar did not write, or cannot be read. See Running drawbard.

drawbar status --json prints the same report as one JSON object, for scripts and monitoring. Status takes the real git from a fresh resolve cache, the way the shim does, and otherwise runs each candidate git with --version. It never writes the resolve cache or any other file. It asks a listening drawbard only for its protocol, with a request every daemon refuses before it runs anything, and waits at most 2 seconds for the answer. It exits 0 once the report is printed and 2 for a bad argument.

Health checks

drawbar doctor checks that the shim is installed and runs ahead of the system git, and that nothing in the git config or your repositories breaks it. It prints one line per check, and under each problem one line that fixes it:

$ drawbar doctor
drawbar doctor 0.1.0

ok    install.binary: /home/acme/.local/opt/drawbar/drawbar is a drawbar binary
ok    install.git: /home/acme/.local/bin/git runs drawbar
ok    install.drawbar: /home/acme/.local/bin/drawbar runs drawbar
ok    install.real-git: the shim runs /home/acme/.local/opt/git-2.56.1/bin/git (git 2.56.1)
ok    install.config: /home/acme/.config/drawbar/config.toml is absent, so the defaults apply
fail  path.order: /usr/bin comes before /home/acme/.local/bin on PATH, so git runs /usr/bin/git and skips the shim
      fix: put ~/.local/bin first on PATH: add `export PATH="$HOME/.local/bin:$PATH"` to your shell profile and start a new shell
fail  path.git: git on PATH is /usr/bin/git, not the drawbar shim
      fix: put /home/acme/.local/bin ahead of /usr/bin on PATH
ok    gitconfig.ref-format: init.defaultRefFormat is files
ok    gitconfig.fsmonitor: the global and system git config do not turn core.fsmonitor on
ok    repos.relative-worktrees: none of 3 configured repositories enables it
ok    repos.lease-lock: the lease is free in 3 of 3 configured repositories
warn  systemd.path: acme-orchestrator.service gets PATH from the user manager without /home/acme/.local/bin, so git run by name in it skips the shim
      fix: run `systemctl --user edit acme-orchestrator.service`, add `Environment="PATH=%h/.local/bin:/usr/local/bin:/usr/bin:/bin"` under [Service], then run `systemctl --user restart acme-orchestrator.service`
ok    daemons.fsmonitor: 4 git fsmonitor--daemon processes use 38.2 MiB RSS and 61004 inotify watches: 4 watching a repository that qualifies
ok    daemons.inotify: 63117 of 524288 inotify watches (fs.inotify.max_user_watches) in use, 61004 of them by fsmonitor daemons
warn  drawbard.daemon: drawbard on /run/user/1000/drawbar/drawbard.sock speaks protocol 1, not this drawbar's 2, so it refuses every fetch and each takes the lease
      fix: restart drawbard so it runs this drawbar: run `systemctl --user restart drawbard.service`

unhealthy: 2 failed, 2 warned
CheckLevelProblem it reports
install.binary, install.git, install.drawbarfail, or warnThe installed copy or a ~/.local/bin entry is missing, is not drawbar, or is a drawbar binary that install did not place, which is a warning.
install.real-gitfailNo real git resolves, so every git call exits 78. When the candidates fail because git cannot read its config, doctor shows git’s error, which names the file.
install.configfailThe shim ignores the config file and uses the defaults.
path.orderfail~/.local/bin is missing from PATH, or comes after /usr/bin.
path.gitfailThe first git on PATH is not the drawbar shim.
gitconfig.ref-formatfail, or warninit.defaultRefFormat is not files, or GIT_DEFAULT_REF_FORMAT names another format. An unset init.defaultRefFormat is a warning.
gitconfig.readfailGit cannot read its global or system config, and names the file in its error.
gitconfig.fsmonitorwarnThe global or system git config, or a file it includes, turns core.fsmonitor on for every repository.
repos.relative-worktreeswarnA configured repository sets extensions.relativeWorktrees to any value, and a git older than 2.48 is installed as the git in a PATH directory, as /usr/bin/git, or as the real git.
repos.lease-lockfail, or warnThis user cannot open a repository’s drawbar-lease.lock, so every leased git there exits 75. A process that has held the lease for at least the lease wait is a warning.
systemd.pathwarnA systemd user service that runs git has no ~/.local/bin on the PATH it runs with, or has /usr/bin ahead of it, or runs a git other than the shim by its path, so its git skips the shim. Linux only.
daemons.fsmonitorwarnA git fsmonitor--daemon is orphaned, excluded, or below the tracked-file threshold, so drawbar gc-daemons would stop it. The message counts the daemons, their total RSS and their inotify watches. Linux only.
daemons.inotifywarnThe user’s inotify watches reach 90% of fs.inotify.max_user_watches. Linux only.
drawbard.daemonwarndrawbard speaks another protocol, so it refuses every fetch; a socket is there but nothing answers; something that is not a socket is at the socket path; the shim will not use the socket because another user could reach or replace it; a drawbard.service, drawbar’s or not, is there but nothing listens, or XDG_RUNTIME_DIR is not set; or the unit file cannot be read. Before it suggests systemctl --user restart drawbard.service, it checks that systemd loads drawbar’s unit file with no drop-ins. When systemd has no file loaded for the unit, or loads another file, the fix says to run systemctl --user daemon-reload and doctor again, and to move that other file only if it still wins. With drop-ins, it says to check systemctl --user cat drawbard.service first. drawbard is optional, so no daemon and no unit passes.

The configured repositories are the maintenance.repo registry that drawbar maintenance runs on, each fsmonitor.include entry that is itself a repository, and the repository in the current directory. Doctor finds each one’s common git directory without running git, so it still reads a repository that an old git cannot open. Linked worktrees of one clone share a common git directory, so they count once.

To tell whether a lease is held, doctor tries a shared lock without waiting and releases it at once. On Linux it finds the holder in /proc/locks, and times the hold from the modification time the shim sets when it takes the lease. When that time is older than the holder’s process, read from /proc/<pid>/stat, the holder could not set it, and doctor reports the hold without timing it. On other platforms it reports a held lease without timing it. Doctor compares the hold with the lease wait the shim uses: DRAWBAR_LEASE_WAIT, else AGENT_GIT_LEASE_WAIT, else lease.timeout_secs.

The systemd.path check inspects drawbar’s own service units, when installed, and each active systemd user service whose command line or environment points at git: an ExecStartPre, ExecStart or ExecStartPost word named git or git-<something>, or a GIT_* variable in its Environment= or its EnvironmentFiles. It leaves the other services out, since most never run git and the user manager’s default PATH would flag every one of them. A service’s effective PATH is the last one its EnvironmentFiles set, else its own Environment=PATH=, else the user manager’s from systemctl --user show-environment, else systemd’s default. The fix names the place that sets it. A service whose Exec line runs a git other than the shim by its absolute path, such as ExecStart=/usr/bin/git fetch, warns too, whatever its PATH. A wildcard EnvironmentFile= is read as a literal file name. Doctor reads all of this with systemctl --user, or the program DRAWBAR_SYSTEMCTL names, and skips the check when systemctl is missing or no user manager answers.

The daemons checks find each git fsmonitor--daemon the way drawbar gc-daemons does and give it the same verdict, without stopping anything. A daemon is watching when its repository still qualifies, orphaned when its repository is gone, and unneeded when it is excluded or below the tracked-file threshold. RSS is each daemon’s VmRSS. The inotify count is the sum of the inotify wd: lines in the fdinfo of every inotify descriptor the user’s processes hold, the same per-user total the kernel holds against fs.inotify.max_user_watches. The count is an estimate: an inotify instance that two descriptors share counts twice. Doctor reads /proc, or the tree DRAWBAR_PROC names, and skips both checks when it cannot.

Doctor reads the git config the way git does outside a repository, with the real git, and leaves out per-process settings such as GIT_CONFIG_PARAMETERS. It changes nothing. drawbar doctor --json prints the report as one JSON object, with healthy, a count per level, and each check’s id, level, message and fix. The level is ok, skip, warn or fail. A check is skipped when something it needs is missing, such as a real git to read the config with, and another check reports that. Doctor exits 0 when no check warned or failed, 1 when one did, and 2 for a bad argument.