Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pin node version #11

Closed
sterliakov opened this issue Oct 18, 2024 · 1 comment · Fixed by #12
Closed

Pin node version #11

sterliakov opened this issue Oct 18, 2024 · 1 comment · Fixed by #12

Comments

@sterliakov
Copy link
Contributor

sterliakov commented Oct 18, 2024

Node 23.0.0 was released 2 days ago and broke hooks in this repository. The log I receive is the following:

An unexpected error has occurred: CalledProcessError: command: ('/home/stas/.cache/pre-commit/repo6fs1kess/node_env-default/bin/node', '/home/stas/.cache/pre-commit/repo6fs1kess/node_env-default/bin/npm', 'pack')
return code: 254
stdout: (none)
stderr:
    (node:2233787) 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:/home/stas/.cache/pre-commit/repo6fs1kess/ (null) seems to be corrupted. Trying again.
    npm warn tarball tarball data for file:/home/stas/.cache/pre-commit/repo6fs1kess/ (null) seems to be corrupted. Trying again.
    npm error code ENOENT
    npm error syscall lstat
    npm error path /home/stas/.cache/pre-commit/repo6fs1kess/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/stas/.cache/pre-commit/repo6fs1kess/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: /home/stas/.npm/_logs/2024-10-18T16_37_40_681Z-debug-0.log
Check the log at /home/stas/.cache/pre-commit/pre-commit.log

NPM log is no more helpful. This is something related to node v23, and pre-commit defaults to using latest version. The problem is that npm pack works, while node npm pack for some reason does not, and pre-commit invokes the latter.

To reproduce (if this doesn't fail, try pre-commit clean prior to running this):

cd $(mktemp -d)
git init
cat >.pre-commit-config.yaml <<EOF
repos:
-   repo: https://github.com/biomejs/pre-commit
    rev: "v0.5.0"
    hooks:
    -   id: biome-check
        additional_dependencies: ["@biomejs/biome"]
EOF
pre-commit install
pre-commit install-hooks

Works:

cd $(mktemp -d)
git init
cat >.pre-commit-config.yaml <<EOF
repos:
-   repo: https://github.com/biomejs/pre-commit
    rev: "v0.5.0"
    hooks:
    -   id: biome-check
        additional_dependencies: ["@biomejs/biome"]
        language_version: '22.0.0'
EOF
pre-commit install
pre-commit install-hooks

language_version can be overridden by end users, but it's expected that hooks work "out of the box", hence pinning language_version here would be very helpful. (to make it clear, this does not depend on system node installation, so won't be exposed to users directly in any way)

@sterliakov
Copy link
Contributor Author

sterliakov commented Oct 18, 2024

Here's an upstream confirmation: already discovered in pre-commit/pre-commit#3339 and caused by nodejs/node#55410. Also good suggestion from that thread to use language_version: lts to avoid pinning to any specific release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant