{"record":{"id":"b534e2c536093610","repo":"yarnpkg/yarn","slug":"toofewarguments-b534e2","errorCode":null,"errorMessage":"tooFewArguments","messagePattern":"tooFewArguments","errorType":"exception","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/cli/commands/unplug.js","lineNumber":30,"sourceCode":"export function hasWrapper(commander: Object): boolean {\n  return true;\n}\n\nexport function setFlags(commander: Object) {\n  commander.description(\n    'Temporarily copies a package (with an optional @range suffix) outside of the global cache for debugging purposes',\n  );\n  commander.usage('unplug [packages ...] [flags]');\n  commander.option('--clear', 'Delete the selected packages');\n  commander.option('--clear-all', 'Delete all unplugged packages');\n}\n\nexport async function run(config: Config, reporter: Reporter, flags: Object, args: Array<string>): Promise<void> {\n  if (!config.plugnplayEnabled) {\n    throw new MessageError(reporter.lang('unplugDisabled'));\n  }\n  if (!args.length && flags.clear) {\n    throw new MessageError(reporter.lang('tooFewArguments', 1));\n  }\n  if (args.length && flags.clearAll) {\n    throw new MessageError(reporter.lang('noArguments'));\n  }\n\n  if (flags.clearAll) {\n    await clearAll(config);\n  } else if (flags.clear) {\n    await clearSome(config, new Set(args));\n  } else if (args.length > 0) {\n    const lockfile = await Lockfile.fromDirectory(config.lockfileFolder, reporter);\n    await wrapLifecycle(config, flags, async () => {\n      const install = new Install(flags, config, reporter, lockfile);\n      install.linker.unplugged = args;\n      await install.init();\n    });\n  }\n","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/cli/commands/unplug.js#L12-L48","documentation":"Thrown by 'yarn unplug' when the --clear flag is supplied but no positional package args are given (args.length === 0). --clear targets specific packages, so omitting them is ambiguous.","triggerScenarios":"Running 'yarn unplug --clear' with no package names, so the condition (!args.length && flags.clear) is true.","commonSituations":"User expects --clear to clear everything (that is --clear-all); forgot to list which packages to clear.","solutions":["Add one or more package names: 'yarn unplug --clear <pkg> [<pkg>...]'.","If you meant to clear all unplugged packages, use '--clear-all' instead of '--clear'."],"exampleFix":"# before\n$ yarn unplug --clear\n# after\n$ yarn unplug --clear lodash\n# or\n$ yarn unplug --clear-all","handlingStrategy":"validation","validationCode":"if (flags.clear && (!Array.isArray(args) || args.length === 0)) {\n  throw new Error(\"'--clear' requires at least one package name; use '--clear-all' to clear everything.\");\n}","typeGuard":"function hasClearTargets(flags: Object, args: string[]): boolean {\n  return Boolean(flags.clear) && args.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Distinguish '--clear <pkgs>' from '--clear-all' in documentation and scripts.","Validate flag/arg combinations in a wrapper script before delegating to Yarn."],"tags":["cli-args","validation","plugnplay"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}