{"record":{"id":"4b45cc27d651df57","repo":"yarnpkg/yarn","slug":"unplugdisabled","errorCode":null,"errorMessage":"unplugDisabled","messagePattern":"unplugDisabled","errorType":"exception","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/cli/commands/unplug.js","lineNumber":27,"sourceCode":"\nconst path = require('path');\n\nexport 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();","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/cli/commands/unplug.js#L9-L45","documentation":"Thrown at the top of 'yarn unplug' run when config.plugnplayEnabled is false. Unplugging copies a package out of the Plug'n'Play (PnP) zip cache for debugging; the operation is meaningless without PnP, so Yarn refuses to proceed.","triggerScenarios":"Running 'yarn unplug [pkg]' in a project installed with the classic node-modules linker (PnP disabled), so config.plugnplayEnabled resolves false.","commonSituations":"Default Yarn install (no PnP); project upgraded from an older Yarn without enabling PnP; .yarnrc.yml lacks 'nodeLinker: pnp' (Yarn 2+) or .yarnrc lacks 'pnp-enable true' (Yarn 1).","solutions":["Enable Plug'n'Play: in Yarn 1 set '--pnp' or add 'pnp-enable true' to .yarnrc, then re-install.","In Yarn 2+ set 'nodeLinker: pnp' in .yarnrc.yml and run 'yarn install'.","If you did not intend to use PnP, do not run 'yarn unplug' — it is PnP-only."],"exampleFix":"# before (.yarnrc)\n# (no pnp setting)\n# after\npnp-enable true","handlingStrategy":"validation","validationCode":"if (!config.plugnplayEnabled) {\n  throw new Error(\"'yarn unplug' requires Plug'n'Play; enable it in .yarnrc/.yarnrc.yml and reinstall.\");\n}","typeGuard":"function isPnpEnabled(config: Config): boolean {\n  return Boolean(config.plugnplayEnabled);\n}","tryCatchPattern":null,"preventionTips":["Enable PnP project-wide before relying on 'unplug'.","Document the chosen node-linker in the repo so all contributors use PnP.","Gate 'unplug' invocations behind a config check in shared scripts."],"tags":["plugnplay","config","installer"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}