nice-florist-55958
11/14/2021, 2:47 AMnice-florist-55958
11/14/2021, 3:05 AMvi
the file and see the contents of __main__.py
if that helps. When I use python_shebang path/to/cached/pex/file/pex
it executes fine (so I'd expect the lint goal to run just fine except for the now even more confusing execution permission error...).enough-analyst-54434
11/14/2021, 3:22 AMnice-florist-55958
11/14/2021, 3:29 AMnice-florist-55958
11/14/2021, 3:29 AM>./pants test tests/streams:streams_tests
22:24:18.35 [INFO] Completed: Building pytest.pex from pytest_default_lockfile.txt
Exception message: 1 Exception encountered:
ProcessExecutionFailure: Process 'Building pytest.pex from pytest_default_lockfile.txt' failed with exit code 1.
stdout:
stderr:
Failed to spawn a job for DistributionTarget(interpreter=PythonInterpreter('/ms/dist/python/PROJ/core/3.7.5-0/.exec/@sys/bin/python3.7', PythonIdentity('/ms/dist/python/PROJ/core/3.7.5-0/.exec/@sys/bin/python3.7', 'cp37', 'cp37m', 'manylinux_2_17_x86_64', (3, 7, 5)))): [Errno 13] Permission denied: 'casper/.cache/pants/named_caches/pex_root/venvs/d5ac5dc9c20a3a9ae674ee7c4b9b4a3a2b069632/9a128dacefb3843fa45de2c0dc225c7ee1cb4d0e/pex'
>ls -la casper/.cache/pants/named_caches/pex_root/venvs/d5ac5dc9c20a3a9ae674ee7c4b9b4a3a2b069632/9a128dacefb3843fa45de2c0dc225c7ee1cb4d0e/pex
lrwxrwxrwx 1 taymarti cc4827 11 Nov 13 21:22 casper/.cache/pants/named_caches/pex_root/venvs/d5ac5dc9c20a3a9ae674ee7c4b9b4a3a2b069632/9a128dacefb3843fa45de2c0dc225c7ee1cb4d0e/pex -> __main__.py
>unzip casper/.cache/pants/named_caches/pex_root/venvs/d5ac5dc9c20a3a9ae674ee7c4b9b4a3a2b069632/9a128dacefb3843fa45de2c0dc225c7ee1cb4d0e/pex
Archive: casper/.cache/pants/named_caches/pex_root/venvs/d5ac5dc9c20a3a9ae674ee7c4b9b4a3a2b069632/9a128dacefb3843fa45de2c0dc225c7ee1cb4d0e/pex
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
note: casper/.cache/pants/named_caches/pex_root/venvs/d5ac5dc9c20a3a9ae674ee7c4b9b4a3a2b069632/9a128dacefb3843fa45de2c0dc225c7ee1cb4d0e/pex may be a plain executable, not an archive
unzip: cannot find zipfile directory in one of casper/.cache/pants/named_caches/pex_root/venvs/d5ac5dc9c20a3a9ae674ee7c4b9b4a3a2b069632/9a128dacefb3843fa45de2c0dc225c7ee1cb4d0e/pex or
casper/.cache/pants/named_caches/pex_root/venvs/d5ac5dc9c20a3a9ae674ee7c4b9b4a3a2b069632/9a128dacefb3843fa45de2c0dc225c7ee1cb4d0e/pex.zip, and cannot find casper/.cache/pants/named_caches/pex_root/venvs/d5ac5dc9c20a3a9ae674ee7c4b9b4a3a2b069632/9a128dacefb3843fa45de2c0dc225c7ee1cb4d0e/pex.ZIP, period.
>
nice-florist-55958
11/14/2021, 3:31 AMenough-analyst-54434
11/14/2021, 3:33 AMpex
/ __main__.py
are the same file - just a plain python source file. That file should have a shebang and you want to check two things:
1. The file perms.
2. The perms of the shebang binary.enough-analyst-54434
11/14/2021, 3:35 AM/ms/dist/...
Interpreter listed above.nice-florist-55958
11/14/2021, 3:40 AM/ms/dist/...
which has permissions -rwxr-xr-x 2
. When I execute /ms/dist/... pex
or pex_python_shebang pex
, no issues. When I just do pex
I get the permission error. Very strange.enough-analyst-54434
11/14/2021, 3:46 AM./pex
directly in your shell?nice-florist-55958
11/14/2021, 3:49 AMpex
the symlink to __main__.py
in the venv. I did notice two more things that might be hints: the shebang has a -sE I didn't notice, but doesn't seem to change anything. The permissions of __main__.py
are -rwxr-xr-x
, but again this should be sufficient to execute without having to do python -sE __main__.py
(I continue to get permission errors just invoking as __main__.py
).enough-analyst-54434
11/14/2021, 3:57 AMnice-florist-55958
11/14/2021, 4:00 AM__main__.py
. When I substitute /ms/dist/...
directly, it works! Seems bash really hates the symlink to the interpter in the hashbang...enough-analyst-54434
11/14/2021, 4:06 AMenough-analyst-54434
11/14/2021, 4:08 AMnice-florist-55958
11/14/2021, 4:12 AMenough-analyst-54434
11/14/2021, 4:18 AMenough-analyst-54434
11/14/2021, 4:26 AMAFS[3] has several benefits over traditional networked file systems, particularly in the areas of security and scalability. One enterprise AFS deployment at Morgan Stanley exceeds 25,000 clients.[4] AFS uses Kerberos for authentication, and implements access control lists on directories for users and groups. Each client caches files on the local filesystem for increased speed on subsequent requests for the same file. This also allows limited filesystem access in the event of a server crash or a network outage.
enough-analyst-54434
11/14/2021, 4:27 AMnice-florist-55958
11/14/2021, 1:03 PMforked_env
is a dict you want to pass to Popen
then just do forked_env.update(os.environ)
or something similar.
To be honest, I am not sure this is really the issue though, since I can't even execute the file when invoked directly, even though I have execute/read permissions, and it works perfectly fine if I use the hashbang explicitly.
Ultimately seems to be some weirdness with our filesystem that I have never encountered before, and Pants just happened to set up the right conditions to expose it.nice-florist-55958
11/14/2021, 2:42 PM_$PANTS_SETUP_CACHE_ in {*LOCAL*: /var/tmp/.cache, *NFS*: ~/.cache, *NFS*: $(rootdir)/../.cache}
X
_$PYTHON_BIN_NAME_ in *{LOCAL*: /usr/bin/python3.6, *AFS*: /ms/dist/python/PROJ/core/3.7.5/exec/bin/python, *NFS*: ~/venv/bin/python (AFS dist symlink), *NFS*: $(rootdir)/.cache/pants/setup/temp_venv/bin/python}
X
_named_caches_di_r in {*DEFAULT=*None -> *NFS:* ~/.cache/pants/named_caches, *CONFIGURED=NFS:* $(rootdir)/../.cache/pants/named_caches}
When named_caches_dir is fixed to the deafult (not specifying anything in pants.toml), then all other combinations work. So there appears to be no issues mixing local host, NFS and AFS storage.
When I configure named_caches_dir to be one level above the project root in ../.cache/pants (where the setup cache is placed, and where I place all the other caches like mypy for the project), the problem arises. Really have no clue why changing named_caches from NFS: ~/.cache to NFS: ../.cache causes this.nice-florist-55958
11/14/2021, 3:08 PMnamed_caches_dir
in pants.toml
explicitly. It doesn't seem to matter the path or filesystem type, it always results in permission denied when attempting to execute (but with no obvious reason why, as using the generated hashbang directly to execute the file works fine). Further, does not seem to be a subprocess/environment issue as the same error occurs when trying to execute the pex directly in user mode. All symlinks and sources have at least r-x
permissions. The only case things work is when you do not specify it and it defaults to ~/.cache/pants/named_caches
.
Also, this is with local_store_dir
set as well, but that does not seem to be an issue as everything works with that set but not named_caches_dir. Interestingly, when I set named_caches_dir and but keep local_store defaulted, I get a different traceback in a lower part of the code (instead of Failed to spawn a job exception, I get the exact place the exception occurred: Line 520 in .../bootstrapper/pex/pex_bootstrapper.py:
`os.execv(venv_pex, [venv_pex] + sys.argv[1:])`onice-florist-55958
11/14/2021, 3:25 PMexport HOME="$(echo ~/test)"
and keep defaults, Pants puts named_caches in ~/test/pants/named_caches
as you would expect, but this time you get No such file or directory
error. That is because the generated shebang points to ../venvs/short/somehash/bin/python
and only ../venvs/short/somehash
exists (1kb blank file that "doesn't exist" when I try to open it; certainly not a python venv).
So similar behavior, slightly different cause. But the pattern seems to be setting named_caches_dir
causes issues with the sandboxed venv in .../venvs/short
either A) non-executable via hashbang but still executable when invoked directly (when directly setting in config) or B) not existing at all (when using default but exporting $HOME
).enough-analyst-54434
11/14/2021, 4:53 PMenough-analyst-54434
11/14/2021, 5:07 PM$ git diff
diff --git a/pants.toml b/pants.toml
index 659f5656e..c08a5bdd3 100644
--- a/pants.toml
+++ b/pants.toml
@@ -1,4 +1,5 @@
[GLOBAL]
+named_caches_dir = "../bob"
print_stacktrace = true
# Enable our custom loose-source plugins.
Force re-doing all work:
$ ./pants --no-process-execution-local-cache fmt lint check test src/python/pants/util::
That completes green. Then I find all venv pexes work when run directly:
$ find -L ../bob/pex_root/venvs/s -name pex -type f | while read pex; do echo "Testing: $pex" && $pex --version && echo; done
Testing: ../bob/pex_root/venvs/s/1bfb4fab/venv/pex
pytest 6.2.5
Testing: ../bob/pex_root/venvs/s/82d69b63/venv/pex
pex, version 21.9b0
Testing: ../bob/pex_root/venvs/s/5a31133d/venv/pex
pytest 6.2.5
Testing: ../bob/pex_root/venvs/s/f09c59fd/venv/pex
pytest 6.2.5
Testing: ../bob/pex_root/venvs/s/cb6f0b2b/venv/pex
3.9.2 (flake8_2020: 1.6.0, flake8_pantsbuild: 2.0.0, mccabe: 0.6.1,
pycodestyle: 2.7.0, pyflakes: 2.3.1) CPython 3.7.12 on Linux
Testing: ../bob/pex_root/venvs/s/cd3599d7/venv/pex
Traceback (most recent call last):
File "../bob/pex_root/venvs/s/cd3599d7/venv/pex", line 143, in <module>
with open(arg) as fp:
FileNotFoundError: [Errno 2] No such file or directory: '--version'
Testing: ../bob/pex_root/venvs/s/8b88955e/venv/pex
mypy 0.910
Testing: ../bob/pex_root/venvs/s/a60f1695/venv/pex
_ _
(_) ___ ___ _ __| |_
| |/ _/ / _ \/ '__ _/
| |\__ \/\_\/| | | |_
|_|\___/\___/\_/ \_/
isort your imports, so you don't have to.
VERSION 5.9.3
Testing: ../bob/pex_root/venvs/s/c65c1a06/venv/pex
pip 20.3.4 from /home/jsirois/dev/pantsbuild/bob/pex_root/venvs/s/c65c1a06/venv/lib/python3.6/site-packages/pip (python 3.6)
Testing: ../bob/pex_root/venvs/s/bcea3bb9/venv/pex
Traceback (most recent call last):
File "../bob/pex_root/venvs/s/bcea3bb9/venv/pex", line 143, in <module>
with open(arg) as fp:
FileNotFoundError: [Errno 2] No such file or directory: '--version'
Testing: ../bob/pex_root/venvs/s/3c8e08ad/venv/pex
pip 20.3.4 from /home/jsirois/dev/pantsbuild/bob/pex_root/venvs/s/3c8e08ad/venv/lib/python3.7/site-packages/pip (python 3.7)
Testing: ../bob/pex_root/venvs/s/ed9e3f5b/venv/pex
autoflake 1.4
Testing: ../bob/pex_root/venvs/s/8b0d38eb/venv/pex
docformatter 1.4
Testing: ../bob/pex_root/venvs/s/23b8d641/venv/pex
pytest 6.2.5
Testing: ../bob/pex_root/venvs/s/1806ef91/venv/pex
pip 20.3.4 from /home/jsirois/dev/pantsbuild/bob/pex_root/venvs/s/1806ef91/venv/lib/python3.7/site-packages/pip (python 3.7)
enough-analyst-54434
11/14/2021, 5:08 PMnice-florist-55958
11/14/2021, 5:23 PMnice-florist-55958
11/14/2021, 5:27 PM