{"record":{"id":"7b15fdf2ab57dc6d","repo":"pypa/pip","slug":"too-many-arguments","errorCode":null,"errorMessage":"Too many arguments","messagePattern":"Too many arguments","errorType":"exception","errorClass":"CommandError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/commands/cache.py","lineNumber":89,"sourceCode":"                \"Need an action (%s) to perform.\",\n                \", \".join(sorted(handler_map)),\n            )\n            return ERROR\n\n        action = args[0]\n\n        # Error handling happens here, not in the action-handlers.\n        try:\n            handler_map[action](options, args[1:])\n        except PipError as e:\n            logger.error(e.args[0])\n            return ERROR\n\n        return SUCCESS\n\n    def get_cache_dir(self, options: Values, args: list[str]) -> None:\n        if args:\n            raise CommandError(\"Too many arguments\")\n\n        logger.info(options.cache_dir)\n\n    def get_cache_info(self, options: Values, args: list[str]) -> None:\n        if args:\n            raise CommandError(\"Too many arguments\")\n\n        num_http_files = len(self._find_http_files(options))\n        num_packages = len(self._find_wheels(options, \"*\"))\n\n        http_cache_location = self._cache_dir(options, \"http-v2\")\n        old_http_cache_location = self._cache_dir(options, \"http\")\n        wheels_cache_location = self._cache_dir(options, \"wheels\")\n        http_cache_size = filesystem.format_size(\n            filesystem.directory_size(http_cache_location)\n            + filesystem.directory_size(old_http_cache_location)\n        )\n        wheels_cache_size = filesystem.format_directory_size(wheels_cache_location)","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/commands/cache.py#L71-L107","documentation":"Raised as CommandError by CacheCommand.get_cache_dir (cache.py:89) when `pip cache dir` is given any positional arguments. The dir subcommand (lines 87-91) takes no arguments: it simply prints options.cache_dir. The `if args:` guard at line 88 rejects extra tokens. The broader CacheCommand.run (lines 61-85) routes args[0] as the action and passes the remainder to the handler, so any token after `dir` triggers this.","triggerScenarios":"`pip cache dir extra`, `pip cache dir /some/path`.","commonSituations":"Assuming `pip cache dir <dir>` sets or inspects a specific cache directory (it does not); copy-pasting a command with a stray token.","solutions":["Run `pip cache dir` with no arguments to print the cache directory.","To use a custom cache directory, set it via the global `--cache-dir <dir>` option before the subcommand."],"exampleFix":"# before\npip cache dir /tmp/mypipcache\n# after\npip --cache-dir /tmp/mypipcache cache dir","handlingStrategy":"validation","validationCode":"# Disallow extra positional args for `pip cache dir`.\ndef validate_cache_dir_args(extra_args):\n    if extra_args:\n        raise ValueError(\"'pip cache dir' takes no arguments; use --cache-dir <dir> globally to change location\")\n    return True","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `pip cache dir` and `pip cache info` with zero positional arguments.","Use the global `--cache-dir` option to point pip at a different cache root."],"tags":["cli-options","cache","arguments","command-error"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}