pyright-python icon indicating copy to clipboard operation
pyright-python copied to clipboard

Race condition when installing node

Open anisse opened this issue 2 years ago • 0 comments

Use case: using pyright in CI ; job runners run on the same machine and same user (but different workspaces). Node is not installed yet. You just sent two commits to be type checked at the same time. It will easily trigger the following race condition:

export PYRIGHT_PYTHON_GLOBAL_NODE=0 PYRIGHT_PYTHON_NODE_VERSION=16.20.1
pyright &
pyright

More details:

 * Install prebuilt node (16.20.1)  * Environment already exists: /home/anisse/.cache/pyright-python/nodeenv
 * Install prebuilt node (16.20.1) ......... done.

Traceback (most recent call last):
  File "/tmp/pyright/lib/python3.10/site-packages/nodeenv.py", line 652, in copytree
    shutil.copytree(s, d, symlinks, ignore)
  File "/usr/lib/python3.10/shutil.py", line 559, in copytree
    return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
  File "/usr/lib/python3.10/shutil.py", line 457, in _copytree
    os.makedirs(dst, exist_ok=dirs_exist_ok)
  File "/usr/lib/python3.10/os.py", line 225, in makedirs
    mkdir(name, mode)
FileExistsError: [Errno 17] File exists: '/home/anisse/.cache/pyright-python/nodeenv/bin'

During handling of the above exception, another exception occurred:

I am not sure it is nodeenv's role to work around that since it is pyright-python that choses the install directory. A potential workaround would be to use a file lock in $XDG_CACHE_HOME/pyright-python-<node-version>.lock

anisse avatar Sep 01 '23 12:09 anisse