Skip to content

Commit

Permalink
Clear stash if system executable is missing (#2050)
Browse files Browse the repository at this point in the history
Signed-off-by: Bernát Gábor <[email protected]>
  • Loading branch information
gaborbernat authored Jan 13, 2021
1 parent 39fdf95 commit 7f83442
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/changelog/2050.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Drop cached python information if the system executable is no longer present (for example when the executable is a
shim and the mapped executable is replaced - such is the case with pyenv) - by :user:`gaborbernat`.
4 changes: 4 additions & 0 deletions src/virtualenv/discovery/cached_py_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def _get_via_file_cache(cls, app_data, path, exe):
of_path, of_st_mtime, of_content = data["path"], data["st_mtime"], data["content"]
if of_path == path_text and of_st_mtime == path_modified:
py_info = cls._from_dict({k: v for k, v in of_content.items()})
sys_exe = py_info.system_executable
if sys_exe is not None and not os.path.exists(sys_exe):
py_info_store.remove()
py_info = None
else:
py_info_store.remove()
if py_info is None: # if not loaded run and save
Expand Down

0 comments on commit 7f83442

Please sign in to comment.