renovatebot / pre-commit-hooks

Pre-commit hooks for Renovate
MIT License
29 stars 7 forks source link

Crash when installing: `enoent ENOENT: no such file or directory` #2460

Open jamesbraza opened 5 days ago

jamesbraza commented 5 days ago

With this pre-commit-config.yaml:

---
default_language_version:
  python: python3
repos:
  - repo: https://github.com/renovatebot/pre-commit-hooks
    rev: 38.124.1
    hooks:
      - id: renovate-config-validator

When installing pre-commit with pre-commit==4.0.1, a coworker of mine is getting this error:

[INFO] Installing environment for https://github.com/renovatebot/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/Users/user/.cache/pre-commit/repou0t83qeh/node_env-default/bin/node', '/Users/user/.cache/pre-commit/repou0t83qeh/node_env-default/bin/npm', 'pack')
return code: 254
stdout: (none)
stderr:
    (node:99944) ExperimentalWarning: Support for loading ES Module in require() is an experimental feature and might change at any time
    (Use `node --trace-warnings ...` to show where the warning was created)
    npm warn tarball tarball data for file:/Users/user/.cache/pre-commit/repou0t83qeh/ (null) seems to be corrupted. Trying again.
    npm warn tarball tarball data for file:/Users/user/.cache/pre-commit/repou0t83qeh/ (null) seems to be corrupted. Trying again.
    npm error code ENOENT
    npm error syscall lstat
    npm error path /Users/user/.cache/pre-commit/repou0t83qeh/ode_env-default/lib/node_modules/npm/node_modules/sprintf-js/dist/.gitattributes
    npm error errno -2
    npm error enoent ENOENT: no such file or directory, lstat '/Users/user/.cache/pre-commit/repou0t83qeh/ode_env-default/lib/node_modules/npm/node_modules/sprintf-js/dist/.gitattributes'
    npm error enoent This is related to npm not being able to find a file.
    npm error enoent
    npm error A complete log of this run can be found in: /Users/user/.npm/_logs/2024-10-17T01_27_47_135Z-debug-0.log
Check the log at /Users/user/.cache/pre-commit/pre-commit.log

Any ideas what went wrong here? I think Renovate should at least nice-ify the failure message hit

jonyscathe commented 5 days ago

Get the same thing on rev 38.120.1 and 38.124.2 with pre-commit 3.8.0 and 4.0.1.

Running an ubuntu 24.04 LTS image in WSL2.

And this was all working fine a couple of days ago (albeit probably a slightly older rev).

jonesbusy commented 5 days ago

Same here... No idea what's going on

Happen on WSL2 but also when running precommit on Jenkins CI.

    npm error path /home/****/.cache/pre-commit/repob_i34tjc/ode_env-default/lib/node_modules/npm/node_modules/sprintf-js/dist/.gitattributes
    npm error errno -2
    npm error enoent ENOENT: no such file or directory, lstat '/home/****/.cache/pre-commit/repob_i34tjc/ode_env-default/lib/node_modules/npm/node_modules/sprintf-js/dist/.gitattributes'
    npm error enoent This is related to npm not being able to find a file.

Tested rev: 38.120.1 and rev: 38.122.0

krakeusz commented 5 days ago

Same for me. Linux Ubuntu 20.04, pre-commit 2.21.0 and 3.5.0. renovatebot 38.124.1. I had to use pre-commit run to trigger this failure.

jonesbusy commented 5 days ago

Looking at logs

24 verbose os Linux 5.15.133.1-microsoft-standard-WSL2
25 verbose node v23.0.0
26 verbose npm  v10.9.0
27 verbose exit -2

Could it be related to recent Node 23 ? Where is it defined ? renovate ? precommit ?

jonesbusy commented 5 days ago

Temporary workarround

  - repo: https://github.com/renovatebot/pre-commit-hooks
    rev: 38.120.1
    hooks:
      - id: renovate-config-validator
        language_version: 20.18.0
jamesbraza commented 5 days ago

An alternate workaround I rolled yesterday was moving from pre-commit to the GitHub Action https://github.com/suzuki-shunsuke/github-action-renovate-config-validator. My thinking is that one doesn't need to revalidate a Renovate config every commit (as the config is static for 99.9% of commits).

jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - uses: suzuki-shunsuke/github-action-renovate-config-validator@v1.1.0
jonyscathe commented 2 days ago

Ok... I had node v18.19.1 installed and was getting this error. I updated node to v23.0.0 and stopped getting this error.

Though now the Installing environment for https://github.com/renovatebot/pre-commit-hooks. step takes a ridiculously long time