Skip to content

pip wheel/install with non-writable cache fails despite warning the cache has been disabled #7488

@sbidoul

Description

@sbidoul

Coming from #7484

Environment

  • pip version: 19.3
  • Python version: 3.7 (probably irrelevant)
  • OS: linux (probably irrelevant)

Description

Running pip install and pip wheel with a non-writable cache directory leads to an install error, despite pip warning that the cache is disabled due to a permission or ownership issue.

Expected behavior

Installation or build should succeed with a warning that the cache is disabled.

How to Reproduce: pip install

$ mkdir cache
$ chmod -r cache
$ pip install wrapt --cache-dir=cache

Output

WARNING: The directory '/tmp/brol/cache/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory 'cache' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: 'cache/wheels/d7/de/2e/efa132238792efb6459a96e85916ef8597fcb3d2ae51590dfd'
Consider using the `--user` option or check the permissions.

pip wheel behaves similarly.

Analysis

For pip install the wheel cache is created before testing the cache is writable.

wheel_cache = WheelCache(options.cache_dir, options.format_control)
if options.cache_dir and not check_path_owner(options.cache_dir):
logger.warning(
"The directory '%s' or its parent directory is not owned "
"by the current user and caching wheels has been "
"disabled. check the permissions and owner of that "
"directory. If executing pip with sudo, you may want "
"sudo's -H flag.",
options.cache_dir,
)
options.cache_dir = None

For pip wheel, no such cache writability check is done.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: cacheDealing with cache and files in itauto-lockedOutdated issues that have been locked by automationtype: bugA confirmed bug or unintended behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions