{"record":{"id":"72b31565257eb345","repo":"pypa/pip","slug":"please-provide-a-pattern","errorCode":null,"errorMessage":"Please provide a pattern","messagePattern":"Please provide a pattern","errorType":"exception","errorClass":"CommandError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/commands/cache.py","lineNumber":170,"sourceCode":"\n        results = []\n        for filename in files:\n            wheel = os.path.basename(filename)\n            size = filesystem.format_file_size(filename)\n            results.append(f\" - {wheel} ({size})\")\n        logger.info(\"Cache contents:\\n\")\n        logger.info(\"\\n\".join(sorted(results)))\n\n    def format_for_abspath(self, files: list[str]) -> None:\n        if files:\n            logger.info(\"\\n\".join(sorted(files)))\n\n    def remove_cache_items(self, options: Values, args: list[str]) -> None:\n        if len(args) > 1:\n            raise CommandError(\"Too many arguments\")\n\n        if not args:\n            raise CommandError(\"Please provide a pattern\")\n\n        files = self._find_wheels(options, args[0])\n\n        no_matching_msg = \"No matching packages\"\n        if args[0] == \"*\":\n            # Only fetch http files if no specific pattern given\n            files += self._find_http_files(options)\n        else:\n            # Add the pattern to the log message\n            no_matching_msg += f' for pattern \"{args[0]}\"'\n\n        if not files:\n            logger.warning(no_matching_msg)\n\n        bytes_removed = 0\n        for filename in files:\n            bytes_removed += os.stat(filename).st_size\n            os.unlink(filename)","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/commands/cache.py#L152-L188","documentation":"Raised by pip cache remove when no positional argument is given. remove_cache_items at cache.py:169 requires a pattern to identify what to delete; without one it cannot proceed. The CommandError is caught in CacheCommand.run and logged.","triggerScenarios":"Invoking `pip cache remove` with no arguments — args[1:] is empty, hitting `if not args` at cache.py:169.","commonSituations":"User runs `pip cache remove` expecting an interactive prompt or a default, or intends to purge but types the wrong subcommand.","solutions":["Provide a pattern: `pip cache remove <package-or-glob>`.","Use `pip cache purge` if the intent is to clear the entire cache.","Run `pip cache list` first to see cached wheel names to target."],"exampleFix":"// before\npip cache remove\n// after\npip cache remove numpy","handlingStrategy":"validation","validationCode":"# Validate before calling pip cache remove\ndef cache_remove(pattern):\n    if not pattern:\n        raise ValueError(\"pip cache remove requires a non-empty pattern\")\n    return subprocess.run([\"pip\", \"cache\", \"remove\", pattern], check=True)\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass a pattern to `pip cache remove`; use `pip cache purge` to clear everything.","Inspect `pip cache list` first to choose a target pattern."],"tags":["cli","pip-cache","argument-validation","usage-error"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}