From 5023ea0feceb5a9cc4931f6be9404d4582cb8502 Mon Sep 17 00:00:00 2001 From: Tomas Orsava Date: Tue, 14 Feb 2017 17:10:09 +0100 Subject: [PATCH] Emit a warning when running with root privileges --- pip/commands/install.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pip/commands/install.py b/pip/commands/install.py index b7e662bd..c1bcf3b5 100644 --- a/pip/commands/install.py +++ b/pip/commands/install.py @@ -192,6 +192,13 @@ class InstallCommand(RequirementCommand): cmdoptions.resolve_wheel_no_use_binary(options) cmdoptions.check_install_build_global(options) + # Check whether we have root privileges + if os.getuid() == 0: + logger.warning( + "WARNING: Running pip install with root privileges is " + "generally not advised. Try `pip install --user` instead." + ) + if options.as_egg: warnings.warn( "--egg has been deprecated and will be removed in the future. " -- 2.11.0