Skip to content

Repeated message about cache being disabled if pip cache is run with sudo #8142

@deveshks

Description

@deveshks

Environment

  • pip version: pip 20.1.dev1
  • Python version: Python 3.8.2
  • OS: Mac OS 10.15.4

Description

Running pip cache commands with sudo print two messages about cache being disabled, one a Warning and other an Error. (The second error message was introduced recently in #8124)

Expected behavior

Ideally only one message should be printed. Or the second message can be supplanted to distinguish the case between using sudo, or using --no-cache-dir (We have options.cache_dir = None in the former, and options.cache_dir = False in the latter

How to Reproduce

Run sudo pip cache <subcommand>

Output

$ sudo pip cache list
WARNING: The directory '/Users/devesh/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

ERROR: pip cache commands can not function since cache is disabled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions