{"id":"0ddbe5fbcdf99e7c","repo":"python-poetry/poetry","slug":"only-specifying-the-package-name-is-not-yet-suppor","errorCode":null,"errorMessage":"Only specifying the package name is not yet supported. Add a specific version to clear","messagePattern":"Only specifying the package name is not yet supported\\. Add a specific version to clear","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"warning","filePath":"src/poetry/console/commands/cache/clear.py","lineNumber":76,"sourceCode":"\n            if not cache_dir.exists():\n                self.line(\n                    f\"No cache entries for {root}\" if root else \"No cache entries\"\n                )\n                return 0\n\n            # Calculate number of entries\n            entries_count = sum(\n                len(files) for _path, _dirs, files in os.walk(str(cache_dir))\n            )\n\n            delete = self.confirm(f\"<question>Delete {entries_count} entries?</>\", True)\n            if not delete:\n                return 0\n\n            cache.flush()\n        elif len(parts) == 2:\n            raise RuntimeError(\n                \"Only specifying the package name is not yet supported. \"\n                \"Add a specific version to clear\"\n            )\n        elif len(parts) == 3:\n            package = canonicalize_name(parts[1])\n            version = parts[2]\n\n            if not cache.has(f\"{package}:{version}\"):\n                self.line(f\"No cache entries for {package}:{version}\")\n                return 0\n\n            delete = self.confirm(f\"Delete cache entry {package}:{version}\", True)\n            if not delete:\n                return 0\n\n            cache.forget(f\"{package}:{version}\")\n        else:\n            raise ValueError(\"Invalid cache key\")","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/console/commands/cache/clear.py#L58-L94","documentation":"Raises RuntimeError in CacheClearCommand.handle() when the cache argument has exactly 2 colon-separated parts (root:package) but no version. Clearing by package name alone — without a specific version — is not implemented, so Poetry explicitly tells the user to add a version. The check at line 75-79 is `elif len(parts) == 2`.","triggerScenarios":"Running `poetry cache clear pypi:requests` — specifying a root and package name but no version. This hits the 2-part branch which is a not-yet-supported operation.","commonSituations":"User wants to clear all cached versions of a package but Poetry only supports per-version clearing. User assumes package-level clearing works.","solutions":["Append a specific version: `poetry cache clear pypi:requests:2.28.0`.","Use `poetry cache clear pypi --all` to clear the entire root cache if per-version targeting is too granular."],"exampleFix":"# before (error)\npoetry cache clear pypi:requests\n# after\npoetry cache clear pypi:requests:2.28.0\n# or clear all\npoetry cache clear pypi --all","handlingStrategy":"validation","validationCode":"def validate_cache_key(cache_arg: str) -> None:\n    parts = cache_arg.split(\":\") if cache_arg else []\n    if len(parts) == 2:\n        raise ValueError(\n            \"Package-only clearing is not supported; add a version:\"\n            f\" {cache_arg}:<version>\"\n        )","typeGuard":"def is_full_cache_key(cache_arg: str) -> bool:\n    parts = cache_arg.split(\":\") if cache_arg else []\n    return len(parts) == 3","tryCatchPattern":null,"preventionTips":["Always include the version: root:package:version (3 segments).","Use --all if you need to clear all versions of a package.","Note that clearing by package name alone (without version) is not yet implemented."],"tags":["cache-command","runtimeerror","unsupported-operation","cli-validation"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}