Skip to content

Commit

Permalink
Fix PEX_ROOT handling for symlinked paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois committed Oct 24, 2024
1 parent 137dc69 commit 812b9f8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Empty file modified pex/bin/pex.py
100755 → 100644
Empty file.
6 changes: 4 additions & 2 deletions pex/cache/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
from pex.third_party import appdirs


_USER_DIR = os.path.expanduser("~")
_CACHE_DIR = appdirs.user_cache_dir(appauthor="pex-tool.org", appname="pex") # type: str
_USER_DIR = os.path.realpath(os.path.expanduser("~"))
_CACHE_DIR = os.path.realpath(
appdirs.user_cache_dir(appauthor="pex-tool.org", appname="pex")
) # type: str


def path(expand_user=True):
Expand Down
2 changes: 1 addition & 1 deletion pex/pex_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def raw_pex_root(self):
@property
def pex_root(self):
# type: () -> str
pex_root = os.path.expanduser(self.raw_pex_root)
pex_root = os.path.realpath(os.path.expanduser(self.raw_pex_root))
if not can_write_dir(pex_root):
tmp_root = safe_mkdtemp()
pex_warnings.warn(
Expand Down
4 changes: 2 additions & 2 deletions pex/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _default_pex_root():
# third party import lifecycle events.
from pex.cache import root as cache_root

return cache_root.path(expand_user=False)
return cache_root.path(expand_user=True)


class Variables(object):
Expand Down Expand Up @@ -796,7 +796,7 @@ def __repr__(self):
# calculations: https://github.com/pex-tool/pex/issues/1154
def _expand_pex_root(pex_root):
# type: (str) -> str
fallback = os.path.expanduser(pex_root)
fallback = os.path.realpath(os.path.expanduser(pex_root))
return os.path.expanduser(Variables.PEX_ROOT.value_or(ENV, fallback=fallback))


Expand Down

0 comments on commit 812b9f8

Please sign in to comment.