From 2c76686afa24ff09f52642a4b72116c2051ae5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven!=20Ragnar=C3=B6k?= Date: Fri, 9 Aug 2024 08:02:50 -0700 Subject: [PATCH] Pass necessary environment variable via sudo. --- src/rosdep2/platforms/pip.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rosdep2/platforms/pip.py b/src/rosdep2/platforms/pip.py index 2055ff68c..933fd3180 100644 --- a/src/rosdep2/platforms/pip.py +++ b/src/rosdep2/platforms/pip.py @@ -172,6 +172,10 @@ class PipInstaller(PackageManagerInstaller): def __init__(self): super(PipInstaller, self).__init__(pip_detect, supports_depends=True) + # Pass necessary environment for pip functionality via sudo + if self.as_root and self.sudo_command != '': + self.sudo_command += ' --preserve-env=PIP_BREAK_SYSTEM_PACKAGES' + def get_version_strings(self): pip_version = importlib_metadata.version('pip') # keeping the name "setuptools" for backward compatibility