Skip to content

PYRIGHT_PYTHON_NODE_VERSION forces NodeJS installation on every "python -m pyright" execution #319

@oneumyvakin

Description

@oneumyvakin

https://github.com/RobertCraigie/pyright-python/blame/795fdcb2cf22164ac105f74fd1f25b5cf6276753/src/pyright/node.py#L50-L50C9

    if path.exists() and not NODE_VERSION:
        log.debug('Binary at %s exists, skipping nodeenv installation', path)
    else:
        log.debug('Installing nodeenv as a binary at %s could not be found', path)
        _install_node_env()

STEPS TO REPRODUCE
Create a docker image by the followin Dockerfile

FROM python:latest

RUN python -m pip install pyright

RUN mkdir /src
ENV PYRIGHT_PYTHON_NODE_VERSION=23.1.0
ENV PYRIGHT_PYTHON_DEBUG=true

RUN python -m pyright --outputjson /src

RUN file /root/.cache/pyright-python/nodeenv/bin/node && \
    ls -la /root/.cache/pyright-python/nodeenv/bin/node && \
    python -m pyright --outputjson /src

ACTUAL RESULT
NodeJS 23.1.0 will be installed two times on every python -m pyright execution

EXPECTED RESULT
NodeJS 23.1.0 will be installed only one time on the first python -m pyright execution

ADDITIONAL INFORMATION

docker build --progress=plain -t pyright:latest .
#0 building with "default" instance using docker driver

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 367B done
#1 DONE 0.0s

#2 [internal] load metadata for docker.io/library/python:latest
#2 DONE 0.0s

#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s

#4 [1/5] FROM docker.io/library/python:latest
#4 DONE 0.0s

#5 [2/5] RUN python -m pip install pyright
#5 CACHED

#6 [3/5] RUN mkdir /src
#6 CACHED

#7 [4/5] RUN python -m pyright --outputjson /src
#7 CACHED

#8 [5/5] RUN file /root/.cache/pyright-python/nodeenv/bin/node &&     ls -la /root/.cache/pyright-python/nodeenv/bin/node &&     python -m pyright /src
#8 0.197 /root/.cache/pyright-python/nodeenv/bin/node: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=8faab1ff1a91864f812561dc1f333fa2fd2d7630, for GNU/Linux 3.2.0, with debug_info, not stripped, too many notes (256)
#8 0.198 -rwxr-xr-x 1 root root 121761992 Oct 24 12:22 /root/.cache/pyright-python/nodeenv/bin/node
#8 1.229 2024-11-02 09:42:23,449 - DEBUG - pyright.utils - Latest pyright-python version is: 1.1.387
#8 1.230 2024-11-02 09:42:23,450 - DEBUG - pyright.node - Checking for global target binary: node
#8 1.230 2024-11-02 09:42:23,450 - DEBUG - pyright.node - Global target binary: node not found
#8 1.230 2024-11-02 09:42:23,450 - DEBUG - pyright.node - Installing binaries using nodeenv
#8 1.230 2024-11-02 09:42:23,450 - DEBUG - pyright.node - Checking for nodeenv node binary
#8 1.230 2024-11-02 09:42:23,450 - DEBUG - pyright.node - Using /root/.cache/pyright-python/nodeenv/bin/node path for binary
#8 1.230 2024-11-02 09:42:23,450 - DEBUG - pyright.node - Installing nodeenv as a binary at /root/.cache/pyright-python/nodeenv/bin/node could not be found
#8 1.230 2024-11-02 09:42:23,450 - DEBUG - pyright.node - Installing nodeenv to /root/.cache/pyright-python/nodeenv
#8 1.230 2024-11-02 09:42:23,450 - DEBUG - pyright.node - Using user specified node version: 23.1.0
#8 1.230 2024-11-02 09:42:23,450 - DEBUG - pyright.node - Running command with args: ['/usr/local/bin/python', '-m', 'nodeenv', '--node', '23.1.0', '--force', '/root/.cache/pyright-python/nodeenv']
#8 1.273  * Environment already exists: /root/.cache/pyright-python/nodeenv
#8 1.273  * Install prebuilt node (23.1.0) ../usr/local/lib/python3.13/site-packages/nodeenv.py:639: DeprecationWarning: Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata. Use the filter argument to control this behavior.
#8 43.16   archive.extractall(src_dir, extract_list)
#8 44.13 ... done.
#8 44.63 2024-11-02 09:43:06,848 - DEBUG - pyright.node - Attempting to prepend /root/.cache/pyright-python/nodeenv/bin to the PATH
#8 44.63 2024-11-02 09:43:06,848 - DEBUG - pyright.node - Found PATH contents: /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#8 44.63 2024-11-02 09:43:06,848 - DEBUG - pyright.node - Using PATH environment variable: /root/.cache/pyright-python/nodeenv/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#8 44.63 2024-11-02 09:43:06,848 - DEBUG - pyright.node - Running nodeenv command with args: ['/root/.cache/pyright-python/nodeenv/bin/node', '/root/.cache/pyright-python/1.1.387/node_modules/pyright/index.js', '/src']
#8 44.80 0 errors, 0 warnings, 0 informations 
#8 DONE 45.1s

#9 exporting to image
#9 exporting layers
#9 exporting layers 0.9s done
#9 writing image sha256:26338d9799f57ce5c697ff052d9ab36794187653eafa6d7fb4b78d3a4c9552e3 done
#9 naming to docker.io/library/pyright:latest 0.0s done
#9 DONE 0.9s

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions