Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEX_ROOT doesn't seem to be honoured for all directories. #155

Closed
KatieLucas-Grapeshot opened this issue Aug 25, 2015 · 2 comments
Closed
Assignees
Labels

Comments

@KatieLucas-Grapeshot
Copy link
Contributor

After setting PEX_ROOT, pex still attempts to write to ~/.pex -- notably trying to create ~/.pex/interpreters.

This is a problem because on our build system the build process's users $HOME is non-writeable.

I suspect that the default values for the flags in pex.py lines 162 and 269 are at fault here; expanding to the $HOME regardless of the PEX_ROOT setting.

(For the time being have worked round this by setting flags explicitly.)

Thanks,
Katie

@jsirois
Copy link
Member

jsirois commented Aug 6, 2019

Sorry for the huge delay, but this issue has been revived through a reference.

How do you set PEX_ROOT? NB: A very confusing aspect of pex is its build time vs runtime behavior.

At build time, if you set PEX_ROOT as an env var or pass the --pex-root flag to the cli, you only set the PEX_ROOT for the build process and not for the runtime of the resulting pex when executed. The pex --help hints at this:

$ pex --help
...
  --pex-root=PEX_ROOT   Specify the pex root used in this invocation of pex.
                        [Default: ~/.pex]
...

So, to set PEX_ROOT at runtime you need to do one of:

  1. Ensure the desired PEX_ROOT environment variable is exported.
  2. Set PEX_ROOT inline if using a shell like bash; ie PEX_ROOT=x ./my.pex ...
  3. Deploy appropriate pexrc files on target machines. These can be in 3 locations:
    1. sibling to the pex file being run in .pexrc
    2. in ~/.pexrc
    3. in /etc/pexrc
      Line in pexrc are env-var lines like PEX_ROOT=y and they are read and applied with the precedence above, a sibling .pexrc having the highest precedence.

We currently offer no option to embed the PEX_ROOT setting in the pex at build time since pexes are generally non-machine specific - they can run anywhere; so the PEX_ROOT embedded in the pex if we supported this might not exist or be appropriate on some target hosts.

@jsirois
Copy link
Member

jsirois commented Aug 6, 2019

I'm going to close this as answered, but if the above explanation is unclear or unsatisfactory for your usecase, please re-open.

@jsirois jsirois closed this as completed Aug 6, 2019
@jsirois jsirois self-assigned this Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants