#979·qmd

qmd update: hook failure kills entire process, silently skipping every later collection

Author: leestroCreated Sep 23, 2026Updated Sep 26, 2026

Summary

qmd update's per-collection update: hook (a shell command run before scanning, e.g. for git pull) has two bugs in updateCollections() (v2.5.3, dist/cli/qmd.js):

  1. It spawns the hook via nodeSpawn("bash", ["-c", yamlCol.update], ...) — a bare "bash" command name relies on PATH resolution in whatever environment invoked the qmd process. In my environment (a Claude Code session's Bash tool), this consistently failed with Error: spawn bash ENOENT, even though bash resolves fine via which bash in the same shell that invoked qmd.
  2. Much more damaging: on any hook failure (non-zero exit, or the spawn itself erroring), the code calls process.exit(exitCode) / process.exit(1) from inside the per-collection loop. This kills the entire qmd update process outright — every collection after the failing one silently never gets scanned. In my case this meant a knowledge collection went 55+ days without being re-indexed, because an unrelated docs collection's git-pull hook was failing on every run and no one noticed (the whole process died with no indication which collections were affected or that later ones were skipped).

Steps to reproduce

  1. Configure two collections in ~/.config/qmd/index.yml; give the first one an update: hook that fails (e.g. a nonexistent binary, or hit the PATH issue above).
  2. Run qmd update.
  3. Observe: the first collection's hook failure kills the process; the second collection is never scanned, with no explicit "N collections skipped" summary.

Expected: a hook failure is logged clearly, and the run continues to scan every other collection regardless. Actual: the whole run aborts silently partway through.

Suggested fix

Both fixes are small and I've verified them locally:

javascript
// 1. Avoid PATH-resolution issues entirely:
const proc = nodeSpawn("/bin/bash", ["-c", yamlCol.update], { ... });

// 2. Don't kill the whole process on one collection's hook failure:
// (inside the per-collection loop, replace both process.exit() calls)
if (exitCode !== 0) {
    console.log(`✗ Update command failed with exit code ${exitCode}`);
    hookFailed = true; // instead of process.exit(exitCode)
}
// ...
catch (err) {
    console.log(`✗ Update command failed: ${err}`);
    hookFailed = true; // instead of process.exit(1)
}
if (hookFailed) {
    console.log(`    Continuing without running this collection's update hook.`);
}

Verified locally (patched the installed package): a deliberately-broken hook on one collection now logs the failure and the run still successfully scans every other collection; the original bash ENOENT also disappeared once hardcoded to /bin/bash.

Happy to open a PR with this diff if useful — wanted to raise the issue first in case there's a reason for the current behavior I'm not seeing (e.g. intentionally treating a hook failure as fatal for that collection specifically, though even then it shouldn't take down collections it hasn't reached yet).