laurent22/joplin · error · Error

Missing required argument: %s

Error message

Missing required argument: %s

What it means

cliUtils.makeCommandArgs parses each command's usage spec (e.g. 'attach <note> <file>') to determine required positional arguments. It iterates the positional slots and, for each one marked required, checks that the caller actually supplied a value at that index; if not, it throws 'Missing required argument'. The message is i18n-translated.

Source

Thrown at packages/app-cli/app/cli-utils.ts:150

			if (flags.long) booleanFlags.push(flags.long);
		}

		if (flags.short && flags.long) {
			aliases[flags.long] = [flags.short];
		}

		flagSpecs.push(flags);
	}

	const args = yargParser(argv, {
		boolean: booleanFlags,
		alias: aliases,
		string: ['_'],
	});

	for (let i = 1; i < parsedUsage['_'].length; i++) {
		const a = cliUtils.parseCommandArg(parsedUsage['_'][i] as string);
		if (a.required && !args['_'][i]) throw new Error(_('Missing required argument: %s', a.name));
		output[a.name] = args['_'][i];
	}

	const argOptions: CommandArgs = {};
	for (const key in args) {
		if (!args.hasOwnProperty(key)) continue;
		if (key === '_') continue;
		argOptions[key] = args[key];
	}

	for (const [key, value] of Object.entries(argOptions)) {
		const flagSpec = flagSpecs.find(s => {
			return s.short === key || s.long === key;
		});
		if (flagSpec?.arg?.required) {
			// If a flag is required, and no value is provided for it, Yargs
			// sets the value to `true`.
			if (value === true) {

View on GitHub (pinned to 2654b33620)

Solutions

  1. Run '<command> --help' or 'help <command>' to see required arguments (denoted by angle brackets).
  2. Supply all required positional arguments in order.
  3. Verify the usage() spec of the command if you are authoring one.

Example fix

# before
#   joplin cat
# after
#   joplin cat "my note"
Defensive patterns

Strategy: validation

Validate before calling

const required = parsedUsage['_'].map((s, i) => i > 0 ? cliUtils.parseCommandArg(s) : null).filter(Boolean);
for (const a of required) {
  if (!userSupplied[a.name]) throw new Error(`Missing required argument: ${a.name}`);
}

Try / catch

try {
  await command.action(cliUtils.makeCommandArgs(command, argv));
} catch (e) {
  if (/Missing required argument/.test(e.message)) command.stdout(command.usage());
}

Prevention

When it happens

Trigger: Running a command without one of its required positional arguments — e.g. 'cat' with no note title, or 'attach file.txt' missing the note argument.

Common situations: Forgetting a required argument; misunderstanding the usage string; shell quoting that swallows an argument.

Related errors


AI-assisted analysis of laurent22/joplin@2654b33620 (2026-08-12). Data as JSON: /api/errors/35bc4959c05ee25d. Report an issue: GitHub.