Skip to content

Discourage usage of pip as root #6409

Closed
@dereisele

Description

@dereisele

What's the problem this feature will solve?
On Manjaro Linux and many other distros, pip tries to install packages in the main library directory (/usr/lib/python37/site-packages), which throws a no permission error. New users than run the same command with sudo. This will result in a messed up library directory when the user installs Python based packages with the system package manager (pacman, apt, ...)

Describe the solution you'd like
I would like a warning or confirmation when pip is run as root (outside a venv) like:
"Running pip as root could result in corruption of the packages directory when a package manager is used. Continue? [yN]"
This confirmation should be able to be bypass with a flag for edge cases like in Docker containers.

Alternative Solutions
Another approach would be to enable the --user flag as default outside venvs.

Additional context
A friend of mine tried to install docker-compose via pacman and was unable to install dependencies like python-requests because pip already created these files. This problem is common and fixing it is tideous work that takes ages.

Disclaimer
I'm on my phone so I can not guarantee correct paths and package names.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions