Bail out only if depot_tools path contains a tilde
Previously, gclient will exit if it found a tilde in any element from
PATH. This CL changes that to first check if the path is the actual
depot_tools directory.
Also check for '~', instead of '~/', in case the path looks like
'~user/path/to/depot_tools/.
Bug: 952865
Change-Id: Ied07444e44edb655b5c8837b5e51eeb0dcebba6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1581419
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
diff --git a/gclient.py b/gclient.py
index d8bd7a7..fd65470 100755
--- a/gclient.py
+++ b/gclient.py
@@ -125,6 +125,8 @@
basestring = str
+DEPOT_TOOLS_DIR = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
+
# Singleton object to represent an unset cache_dir (as opposed to a disabled
# one, e.g. if a spec explicitly says `cache_dir = None`.)
UNSET_CACHE_DIR = object()
@@ -3100,7 +3102,8 @@
def path_contains_tilde():
for element in os.environ['PATH'].split(os.pathsep):
- if element.startswith('~/'):
+ if element.startswith('~') and os.path.abspath(
+ os.path.realpath(os.path.expanduser(element))) == DEPOT_TOOLS_DIR:
return True
return False