Skip to content

Commit

Permalink
Discourage usage of pip as root
Browse files Browse the repository at this point in the history
  • Loading branch information
winsonluk committed Dec 29, 2020
1 parent 7edb8eb commit b4f004f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@ def add_options(self):
@with_cleanup
def run(self, options, args):
# type: (Values, List[str]) -> int
if os.geteuid() == 0:
sudo_warning = ("Running pip as root is not recommended. "
"This could result in the corruption of the package "
"directories when a package manager is used. "
"See #6409 for more details.")
logger.warn(sudo_warning)
if options.use_user_site and options.target_dir is not None:
raise CommandError("Can not combine '--user' and '--target'")

Expand Down

0 comments on commit b4f004f

Please sign in to comment.