Repository: pypa/pip

Issue:
Pip cache reports "Nothing cached" and "Number of wheels: 0" even when wheels are obviously cached
### Description

pip reports "Number of wheels: 0" and "Nothing cached" even when things are obviously cached, as evidenced by "Using cached ...".

This was previously discussed at #7890, where after some time @uranusjr appears to understand the issue and says

> please open a new issue for discussion.

I don't think a new issue was ever opened, so I'm doing that now.

Other relevant comments on that issue are

* https://github.com/pypa/pip/issues/7890#issuecomment-926394424 the same issue
* https://github.com/pypa/pip/issues/7890#issuecomment-944909564 the same issue
* https://github.com/pypa/pip/issues/7890#issuecomment-944953373 the current texts are perhaps technically correct, but as evidenced by this comment not even understandable by pip maintainers.
* https://github.com/pypa/pip/issues/7890#issuecomment-945073779 an explanation of the root cause

### pip version

20.3.4

### Python version

3.9

### OS

Ubuntu

### How to Reproduce


```
/tmp$ python -m venv pip-cache-broken
/tmp$ . pip-cache-broken/bin/activate
(pip-cache-broken) /tmp$ mkdir /tmp/broken-cache-dir
(pip-cache-broken) /tmp$ pip install requests --cache-dir=/tmp/broken-cache-dir
Collecting requests
  Downloading requests-2.28.1-py3-none-any.whl (62 kB)
     |████████████████████████████████| 62 kB 1.4 MB/s 
Collecting charset-normalizer<3,>=2
  Downloading charset_normalizer-2.1.0-py3-none-any.whl (39 kB)
Collecting certifi>=2017.4.17
  Downloading certifi-2022.6.15-py3-none-any.whl (160 kB)
     |████████████████████████████████| 160 kB 9.6 MB/s 
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.10-py2.py3-none-any.whl (139 kB)
     |████████████████████████████████| 139 kB 9.5 MB/s 
Collecting idna<4,>=2.5
  Downloading idna-3.3-py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 7.4 MB/s 
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests
Successfully installed certifi-2022.6.15 charset-normalizer-2.1.0 idna-3.3 requests-2.28.1 urllib3-1.26.10
(pip-cache-broken) /tmp$ pip cache info --cache-dir=/tmp/broken-cache-dir
Package index page cache location: /tmp/broken-cache-dir/http
Package index page cache size: 520 kB
Number of HTTP files: 10
Wheels location: /tmp/broken-cache-dir/wheels
Wheels size: 0 bytes
Number of wheels: 0
(pip-cache-broken) /tmp$ pip cache list --cache-dir=/tmp/broken-cache-dir
Nothing cached.

$ pip install requests --force-reinstall --cache-dir=/tmp/broken-cache-dir
Collecting requests
  Using cached requests-2.28.1-py3-none-any.whl (62 kB)
Collecting charset-normalizer<3,>=2
  Using cached charset_normalizer-2.1.0-py3-none-any.whl (39 kB)
Collecting idna<4,>=2.5
  Using cached idna-3.3-py3-none-any.whl (61 kB)
Collecting urllib3<1.27,>=1.21.1
  Using cached urllib3-1.26.10-py2.py3-none-any.whl (139 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2022.6.15-py3-none-any.whl (160 kB)
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests
  Attempting uninstall: urllib3
    Found existing installation: urllib3 1.26.10
    Uninstalling urllib3-1.26.10:
      Successfully uninstalled urllib3-1.26.10
  Attempting uninstall: idna
    Found existing installation: idna 3.3
    Uninstalling idna-3.3:
      Successfully uninstalled idna-3.3
  Attempting uninstall: charset-normalizer
    Found existing installation: charset-normalizer 2.1.0
    Uninstalling charset-normalizer-2.1.0:
      Successfully uninstalled charset-normalizer-2.1.0
  Attempting uninstall: certifi
    Found existing installation: certifi 2022.6.15
    Uninstalling certifi-2022.6.15:
      Successfully uninstalled certifi-2022.6.15
  Attempting uninstall: requests
    Found existing installation: requests 2.28.1
    Uninstalling requests-2.28.1:
      Successfully uninstalled requests-2.28.1
Successfully installed certifi-2022.6.15 charset-normalizer-2.1.0 idna-3.3 requests-2.28.1 urllib3-1.26.10
```

### Code of Conduct

- [X] I agree to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).


Discussion:

Resolving patch:
diff --git a/src/pip/_internal/commands/cache.py b/src/pip/_internal/commands/cache.py
--- a/src/pip/_internal/commands/cache.py
+++ b/src/pip/_internal/commands/cache.py
@@ -105,9 +105,9 @@ def get_cache_info(self, options: Values, args: List[Any]) -> None:
                     Package index page cache location: {http_cache_location}
                     Package index page cache size: {http_cache_size}
                     Number of HTTP files: {num_http_files}
-                    Wheels location: {wheels_cache_location}
-                    Wheels size: {wheels_cache_size}
-                    Number of wheels: {package_count}
+                    Locally built wheels location: {wheels_cache_location}
+                    Locally built wheels size: {wheels_cache_size}
+                    Number of locally built wheels: {package_count}
                 """
             )
             .format(
@@ -140,7 +140,7 @@ def list_cache_items(self, options: Values, args: List[Any]) -> None:
 
     def format_for_human(self, files: List[str]) -> None:
         if not files:
-            logger.info("Nothing cached.")
+            logger.info("No locally built wheels cached.")
             return
 
         results = []


Test patch:
diff --git a/tests/functional/test_cache.py b/tests/functional/test_cache.py
--- a/tests/functional/test_cache.py
+++ b/tests/functional/test_cache.py
@@ -210,9 +210,9 @@ def test_cache_info(
     result = script.pip("cache", "info")
 
     assert f"Package index page cache location: {http_cache_dir}" in result.stdout
-    assert f"Wheels location: {wheel_cache_dir}" in result.stdout
+    assert f"Locally built wheels location: {wheel_cache_dir}" in result.stdout
     num_wheels = len(wheel_cache_files)
-    assert f"Number of wheels: {num_wheels}" in result.stdout
+    assert f"Number of locally built wheels: {num_wheels}" in result.stdout
 
 
 @pytest.mark.usefixtures("populate_wheel_cache")
@@ -242,9 +242,9 @@ def test_cache_list_abspath(script: PipTestEnvironment) -> None:
 @pytest.mark.usefixtures("empty_wheel_cache")
 def test_cache_list_with_empty_cache(script: PipTestEnvironment) -> None:
     """Running `pip cache list` with an empty cache should print
-    "Nothing cached." and exit."""
+    "No locally built wheels cached." and exit."""
     result = script.pip("cache", "list")
-    assert result.stdout == "Nothing cached.\n"
+    assert result.stdout == "No locally built wheels cached.\n"
 
 
 @pytest.mark.usefixtures("empty_wheel_cache")