tobi/qmd · error · Error

Collection name is required. Collections must be defined in

Error message

Collection name is required. Collections must be defined in ~/.config/qmd/index.yml

What it means

Thrown during the index command when no collection name could be resolved for the current directory. Collections must be declared in ~/.config/qmd/index.yml (or project .qmd/index.yml); the indexer will not guess a name.

Source

Thrown at src/cli/qmd.ts:1917

  yamlRenameCollectionFn(oldName, newName);
  closeDb();

  console.log(`${c.green}✓${c.reset} Renamed collection '${oldName}' to '${newName}'`);
  console.log(`  Virtual paths updated: ${c.cyan}qmd://${oldName}/${c.reset} → ${c.cyan}qmd://${newName}/${c.reset}`);
}

async function indexFiles(pwd?: string, globPattern: string = DEFAULT_GLOB, collectionName?: string, suppressEmbedNotice: boolean = false, ignorePatterns?: string[]): Promise<void> {
  const db = getDb();
  const resolvedPwd = pwd || getPwd();
  const now = new Date().toISOString();
  const excludeDirs = ["node_modules", ".git", ".cache", "vendor", "dist", "build"];

  // Clear Ollama cache on index
  clearCache(db);

  // Collection name must be provided (from YAML)
  if (!collectionName) {
    throw new Error("Collection name is required. Collections must be defined in ~/.config/qmd/index.yml");
  }

  console.log(`Collection: ${resolvedPwd} (${globPattern})`);

  progress.indeterminate();
  const allIgnore = [
    ...excludeDirs.map(d => `**/${d}/**`),
    ...(ignorePatterns || []),
  ];
  const allFiles: string[] = await fastGlob(splitGlobMask(globPattern), {
    cwd: resolvedPwd,
    onlyFiles: true,
    followSymbolicLinks: false,
    dot: false,
    ignore: allIgnore,
  });
  // Filter hidden files/folders (dot: false handles top-level but not nested)
  const files = allFiles.filter(file => {

View on GitHub (pinned to dbfd0b4736)

Solutions

  1. Check ~/.config/qmd/index.yml has an entry whose path covers the cwd and includes a name
  2. Re-add the collection properly: `qmd collection add . --name <n>` from the project root
  3. Verify with `qmd collection list` that the collection and name exist

Example fix

# before (~/.config/qmd/index.yml)
collections:
  - path: ~/notes
# after
collections:
  - path: ~/notes
    name: notes
Defensive patterns

Strategy: validation

Validate before calling

const cfg = parse(readFileSync(join(homedir(), '.config/qmd/index.yml'), 'utf8'));
const cwd = process.cwd();
const hasCoveringNamedCollection = (cfg.collections ?? []).some(c => c.name && cwd.startsWith(resolve(c.path)));

Type guard

const collectionCovers = (c: {path: string; name?: string}, cwd: string) => Boolean(c.name) && (resolve(cwd) + '/').startsWith(resolve(c.path) + '/');

Prevention

When it happens

Trigger: Running `qmd update`/index in a directory that is not under any configured collection root, or when the YAML config lacks a name for the matching path.

Common situations: Hand-edited index.yml missing the name field; running qmd from a subdirectory not covered by any collection path; config file at the wrong location.

Related errors


AI-assisted analysis of tobi/qmd@dbfd0b4736 (2026-08-28). Data as JSON: /api/errors/671b29abf0bb3777. Report an issue: GitHub.