microsoft / pyright

Static Type Checker for Python
Other
13.41k stars 1.47k forks source link

1.1.382 fails to install Node #9075

Closed markrian closed 1 month ago

markrian commented 1 month ago

Describe the bug

It seems pyright 1.1.382 fails to install a working copy of Node, whereas 1.1.381 can.

Code or Screenshots

Reproduction:

$ docker run -it python:3.11.4 /bin/sh -c 'pip install pyright==1.1.382; pyright --version'
Collecting pyright==1.1.382
  Downloading pyright-1.1.382-py3-none-any.whl (18 kB)
Collecting nodeenv>=1.6.0 (from pyright==1.1.382)
  Downloading nodeenv-1.9.1-py2.py3-none-any.whl (22 kB)
Collecting typing-extensions>=4.1 (from pyright==1.1.382)
  Downloading typing_extensions-4.12.2-py3-none-any.whl (37 kB)
Installing collected packages: typing-extensions, nodeenv, pyright
Successfully installed nodeenv-1.9.1 pyright-1.1.382 typing-extensions-4.12.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[notice] A new release of pip is available: 23.1.2 -> 24.2
[notice] To update, run: pip install --upgrade pip
 * Install prebuilt node (22.9.0) ..... done.
/usr/bin/env: ‘node’: No such file or directory
Traceback (most recent call last):
  File "/usr/local/bin/pyright", line 8, in <module>
    sys.exit(entrypoint())
             ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyright/cli.py", line 31, in entrypoint
    sys.exit(main(sys.argv[1:]))
             ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyright/cli.py", line 18, in main
    return run(*args, **kwargs).returncode
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyright/cli.py", line 22, in run
    pkg_dir = install_pyright(args, quiet=None)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyright/_utils.py", line 63, in install_pyright
    node.run(
  File "/usr/local/lib/python3.11/site-packages/pyright/node.py", line 173, in run
    subprocess.run(node_args, **kwargs),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/root/.cache/pyright-python/nodeenv/bin/npm', 'install', 'pyright@1.1.382']' returned non-zero exit status 127.

You can see it works correctly still with 1.1.381:

$ docker run -it python:3.11.4 /bin/sh -c 'pip install pyright==1.1.381; pyright --version'
Collecting pyright==1.1.381
  Downloading pyright-1.1.381-py3-none-any.whl (18 kB)
Collecting nodeenv>=1.6.0 (from pyright==1.1.381)
  Downloading nodeenv-1.9.1-py2.py3-none-any.whl (22 kB)
Installing collected packages: nodeenv, pyright
Successfully installed nodeenv-1.9.1 pyright-1.1.381
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[notice] A new release of pip is available: 23.1.2 -> 24.2
[notice] To update, run: pip install --upgrade pip
WARNING: there is a new pyright version available (v1.1.381 -> v1.1.382).
Please install the new version or set PYRIGHT_PYTHON_FORCE_VERSION to `latest`

 * Install prebuilt node (22.9.0) ..... done.

added 1 package, and audited 2 packages in 1s

found 0 vulnerabilities
pyright 1.1.381
markrian commented 1 month ago

1.1.382 does work if you have node in PATH (I'm assuming that's how it determines whether or not to install Node), but it fails in a virtualenv where node is not available. So it's not isolated to some weird interaction with the python docker image.

bersbersbers commented 1 month ago

Wrong repository - you want https://github.com/RobertCraigie/pyright-python.

Also try installing pyright[nodejs].

markrian commented 1 month ago

Aha! Apologies, I didn't realise the PyPI package is community maintained. Also, thanks for the tip about the nodejs optional dependency, good to know.

Closing.

bersbersbers commented 1 month ago

fyi, your issue was fixed in 1.1.382.post0, see https://github.com/RobertCraigie/pyright-python/issues/304