nanocoai/nanoclaw · error · Error

Provide --apt <pkg> or --npm <pkg>

Error message

Provide --apt <pkg> or --npm <pkg>

What it means

Thrown by `ncl groups config add-package` when neither `--apt` nor `--npm` is provided. The handler requires exactly one package spec per invocation because apt and npm package lists are stored in separate JSON columns (`packages_apt`, `packages_npm`).

Source

Thrown at src/cli/resources/groups.ts:500

        await updateContainerConfigJson(id, 'mcp_servers', servers);

        return { removed: name };
      },
    },
    'config add-package': {
      access: 'approval',
      description:
        'Add a package to a group. Requires `ncl groups restart --rebuild` to take effect. Use --id <group-id> and --apt <pkg> or --npm <pkg>.',
      handler: async (args) => {
        const id = args.id as string;
        if (!id) throw new Error('--id is required');

        const row = await getContainerConfig(id);
        if (!row) throw new Error(`No container config for group: ${id}`);

        const apt = args.apt as string | undefined;
        const npm = args.npm as string | undefined;
        if (!apt && !npm) throw new Error('Provide --apt <pkg> or --npm <pkg>');

        if (apt) {
          const existing = JSON.parse(row.packages_apt) as string[];
          if (!existing.includes(apt)) {
            existing.push(apt);
            await updateContainerConfigJson(id, 'packages_apt', existing);
          }
        }
        if (npm) {
          const existing = JSON.parse(row.packages_npm) as string[];
          if (!existing.includes(npm)) {
            existing.push(npm);
            await updateContainerConfigJson(id, 'packages_npm', existing);
          }
        }

        return {
          added: { apt: apt || null, npm: npm || null },

View on GitHub (pinned to 294ef2aee8)

Solutions

  1. Add the flag: `--apt <pkg>` for system packages or `--npm <pkg>` for node packages
  2. Run one package per invocation — the handler reads, pushes, and rewrites the whole JSON array each time

Example fix

# before
ncl groups config add-package --id my-group
# after
ncl groups config add-package --id my-group --apt ripgrep
Defensive patterns

Strategy: validation

Validate before calling

if (!apt && !npm) { console.error('pass --apt <pkg> or --npm <pkg>'); process.exit(1); }

Type guard

const hasPkgFlag = (a: { apt?: string; npm?: string }) => Boolean(a.apt || a.npm);

Prevention

When it happens

Trigger: `ncl groups config add-package --id <group-id>` with no package flag, or with an empty value like `--apt ""`.

Common situations: Operator assumes the command is interactive; script passes a variable that expanded to nothing; user thinks the package name is positional.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of nanocoai/nanoclaw@294ef2aee8 (2026-08-28). Data as JSON: /api/errors/d585c6a8e3b85db5. Report an issue: GitHub.