From 8d0c4d3cec4973a2722652bf33f093ac3f1f385a Mon Sep 17 00:00:00 2001 From: Nikhil Mitra Date: Thu, 4 Apr 2019 19:28:16 -0700 Subject: [PATCH] Resolve path in get_cached_default_environment() in api/environment.py to prevent unnecessary cache busting when using pipenv. --- jedi/api/environment.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jedi/api/environment.py b/jedi/api/environment.py index 0d2b6729..9fbdeacf 100644 --- a/jedi/api/environment.py +++ b/jedi/api/environment.py @@ -234,7 +234,12 @@ def _try_get_same_env(): def get_cached_default_environment(): var = os.environ.get('VIRTUAL_ENV') environment = _get_cached_default_environment() - if var and var != environment.path: + + # Under macOS in some cases - notably when using Pipenv - the + # sys.prefix of the virtualenv is /path/to/env/bin/.. instead of + # /path/to/env so we need to fully resolve the paths in order to + # compare them. + if var and os.path.realpath(var) != os.path.realpath(environment.path): _get_cached_default_environment.clear_cache() return _get_cached_default_environment() return environment