<#2203 The Pex CLI does not work when run from a r...
# github-notifications
c
#2203 The Pex CLI does not work when run from a read-only venv. Issue created by jsirois Works fine in a typical venv:
Copy code
$ python3.10 -mvenv pex.venv
$ pex.venv/bin/pip -q install -U pip
$ pex.venv/bin/pip -q install -U pex
$ rm -rf ~/.pex
$ pex.venv/bin/pex3 lock create cowsay --indent 2 -o lock.json
running egg_info
writing cowsay.egg-info/PKG-INFO
writing dependency_links to cowsay.egg-info/dependency_links.txt
writing entry points to cowsay.egg-info/entry_points.txt
writing top-level names to cowsay.egg-info/top_level.txt
reading manifest file 'cowsay.egg-info/SOURCES.txt'
reading manifest template '<http://MANIFEST.in|MANIFEST.in>'
writing manifest file 'cowsay.egg-info/SOURCES.txt'
running dist_info
creating /tmp/tmplrzt483o/build/cowsay.egg-info
writing /tmp/tmplrzt483o/build/cowsay.egg-info/PKG-INFO
writing dependency_links to /tmp/tmplrzt483o/build/cowsay.egg-info/dependency_links.txt
writing entry points to /tmp/tmplrzt483o/build/cowsay.egg-info/entry_points.txt
writing top-level names to /tmp/tmplrzt483o/build/cowsay.egg-info/top_level.txt
writing manifest file '/tmp/tmplrzt483o/build/cowsay.egg-info/SOURCES.txt'
reading manifest file '/tmp/tmplrzt483o/build/cowsay.egg-info/SOURCES.txt'
reading manifest template '<http://MANIFEST.in|MANIFEST.in>'
writing manifest file '/tmp/tmplrzt483o/build/cowsay.egg-info/SOURCES.txt'
creating '/tmp/tmplrzt483o/build/cowsay.dist-info'
adding license file "LICENSE.txt" (matched pattern "LICEN[CS]E*")
$ pex.venv/bin/pex --lock lock.json cowsay -c cowsay -- 'Moo!'
  ____
| Moo! |
  ====
    \
     \
       ^__^
       (oo)\_______
       (__)\       )\/\
           ||----w |
           ||     ||
But in a read-only venv Pex commands fail like so:
Copy code
$ rm -rf ~/.pex
$ chmod -R -w pex.venv/lib/python3.10/site-packages
$ pex.venv/bin/pex3 lock create cowsay --indent 2 -o lock.json
Failed to spawn a job for /home/jsirois/support/pex/phaer/pex.venv/bin/python3.10: [Errno 13] Permission denied: '/home/jsirois/.pex/pip/20.3.4-patched/pip.pex/d391aba428cc037d796ca2e7c83909a1db40f322.lck.work/.bootstrap/pex/__init__.py'
The issue here is that Pex trips over itself when constructing the
.bootstrap
by attempting to copy
pex/__init__.py
and other root
pex.*
package
__init__.py
files multiple times. The 1st copy works, but since the source file is read only, the destination file is as well, and subsequent copies (over-writes), fail. This issue was brought to light by NixOS/nixpkgs#246448 where read-only venvs - which are not typically a thing, are used by Nix. pantsbuild/pex