Skip to content

Error when trying to run pre-commit install --install-hooks due to nodeenv.py #3556

@martinm37

Description

@martinm37

search you tried in the issue tracker

is:issue pre-commit install --install-hooks nodeenv pkg_resources

describe your issue

Hello, I have tried running pre-commit install --install-hooks, but there seems to be an error with pkg_resources being deprecated, and error is in the file of nodeenv.py, with the error being IndexError: list index out of range. Could you please advice me how to fix this? Is this an issue with pre-commit or this is an upstream issue? Thank you.

pre-commit --version

pre-commit version: 3.6.2

.pre-commit-config.yaml

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
    -   id: trailing-whitespace
    -   id: end-of-file-fixer
    -   id: check-yaml
    -   id: check-added-large-files

-   repo: https://github.com/pycqa/isort
    rev: 5.13.2
    hooks:
    -   id: isort
        name: isort (python)

-   repo: https://github.com/psf/black
    rev: 24.4.2
    hooks:
    -   id: black
        language_version: python3

-   repo: https://github.com/codespell-project/codespell
    rev: v2.3.0
    hooks:
    -   id: codespell
        exclude: "\\.(json)$|docs/_static/preview"
        args:
        -   --ignore-words-list=vas

-   repo: https://github.com/RobertCraigie/pyright-python
    rev: v1.1.403
    hooks:
    -   id: pyright
        additional_dependencies:
        -   pytest
        -   ipython == 8.12.3
        -   django
        -   flask
        -   trio
        -   flaky
        -   numpy
        -   nox
        -   requests
        -   greenlet
        -   types-click
        -   types-requests
        -   falcon
        -   litestar
        -   aiohttp


-   repo: local
    hooks:
    -   id: build
        name: build js bundle
        entry: bin/build_js_bundle.py --force
        files: html_renderer/.*
        language: node
        pass_filenames: false

-   repo: https://github.com/asottile/pyupgrade
    rev: v3.17.0
    hooks:
    -   id: pyupgrade
        args: [--py37-plus]
        stages: [manual]
        exclude: ^pyinstrument/vendor/

exclude: ^pyinstrument/renderers/html_resources/app.js$|^pyinstrument/vendor

~/.cache/pre-commit/pre-commit.log (if present)

version information

pre-commit version: 3.6.2
git --version: git version 2.51.0
sys.version:
    3.12.3 (main, Jul 31 2024, 17:43:48) [GCC 13.2.0]
sys.executable: /usr/bin/python3
os.name: posix
sys.platform: linux

error information

An unexpected error has occurred: CalledProcessError: command: ('/usr/bin/python3', '-mnodeenv', '--prebuilt', '--clean-src', '/home/martin/.cache/pre-commit/repou6qf2l43/node_env-default')
return code: 1
stdout: (none)
stderr:
    /usr/lib/python3/dist-packages/nodeenv.py:24: DeprecationWarning: 'pipes' is deprecated and slated for removal in Python 3.13
      import pipes
    /usr/lib/python3/dist-packages/nodeenv.py:37: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
      from pkg_resources import parse_version
    Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File "/usr/lib/python3/dist-packages/nodeenv.py", line 1042, in <module>
        main()
      File "/usr/lib/python3/dist-packages/nodeenv.py", line 881, in main
        opt.node = get_last_stable_node_version()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3/dist-packages/nodeenv.py", line 835, in get_last_stable_node_version
        return links[-1][0]
               ~~~~~^^^^
    IndexError: list index out of range
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pre_commit/error_handler.py", line 73, in error_handler
    yield
  File "/usr/lib/python3/dist-packages/pre_commit/main.py", line 399, in main
    return install(
           ^^^^^^^^
  File "/usr/lib/python3/dist-packages/pre_commit/commands/install_uninstall.py", line 139, in install
    install_hooks(config_file, store)
  File "/usr/lib/python3/dist-packages/pre_commit/commands/install_uninstall.py", line 145, in install_hooks
    install_hook_envs(all_hooks(load_config(config_file), store), store)
  File "/usr/lib/python3/dist-packages/pre_commit/repository.py", line 238, in install_hook_envs
    _hook_install(hook)
  File "/usr/lib/python3/dist-packages/pre_commit/repository.py", line 94, in _hook_install
    lang.install_environment(
  File "/usr/lib/python3/dist-packages/pre_commit/languages/node.py", line 89, in install_environment
    cmd_output_b(*cmd)
  File "/usr/lib/python3/dist-packages/pre_commit/util.py", line 111, in cmd_output_b
    raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/usr/bin/python3', '-mnodeenv', '--prebuilt', '--clean-src', '/home/martin/.cache/pre-commit/repou6qf2l43/node_env-default')
return code: 1
stdout: (none)
stderr:
    /usr/lib/python3/dist-packages/nodeenv.py:24: DeprecationWarning: 'pipes' is deprecated and slated for removal in Python 3.13
      import pipes
    /usr/lib/python3/dist-packages/nodeenv.py:37: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
      from pkg_resources import parse_version
    Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      File "/usr/lib/python3/dist-packages/nodeenv.py", line 1042, in <module>
        main()
      File "/usr/lib/python3/dist-packages/nodeenv.py", line 881, in main
        opt.node = get_last_stable_node_version()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3/dist-packages/nodeenv.py", line 835, in get_last_stable_node_version
        return links[-1][0]
               ~~~~~^^^^
    IndexError: list index out of range

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions