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

Unable to install pre-commit hook #13

Closed
gfringeli opened this issue Oct 21, 2024 · 4 comments
Closed

Unable to install pre-commit hook #13

gfringeli opened this issue Oct 21, 2024 · 4 comments

Comments

@gfringeli
Copy link

We have the following hook configuration (.pre-commit-config.yaml)

repos:
  # ... other hooks
  - repo: https://github.com/biomejs/pre-commit
    rev: v0.5.0
    hooks:
      - id: biome-check
        additional_dependencies: ["@biomejs/biome@1.9.3"]
        files: "\\.(jsx?|tsx?|c(js|ts)|m(js|ts)|d\\.(ts|cts|mts)|css|svelte|vue|astro|graphql|gql)$"

Unfortunately, trying to install the hook results in the following error:

$ pre-commit install --install-hooks
pre-commit installed at .git/hooks/pre-commit
[INFO] Installing environment for https://github.com/biomejs/pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/home/ubuntu/.cache/pre-commit/repo4a1_g8oc/node_env-default/bin/node', '/home/ubuntu/.cache/pre-commit/repo4a1_g8oc/node_env-default/bin/npm', 'pack')
return code: 254
stdout: (none)
stderr:
    (node:2830) 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/ubuntu/.cache/pre-commit/repo4a1_g8oc/ (null) seems to be corrupted. Trying again.
    npm warn tarball tarball data for file:/home/ubuntu/.cache/pre-commit/repo4a1_g8oc/ (null) seems to be corrupted. Trying again.
    npm error code ENOENT
    npm error syscall lstat
    npm error path /home/ubuntu/.cache/pre-commit/repo4a1_g8oc/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/ubuntu/.cache/pre-commit/repo4a1_g8oc/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/ubuntu/.npm/_logs/2024-10-21T10_08_37_524Z-debug-0.log
Check the log at /home/ubuntu/.cache/pre-commit/pre-commit.log

We observe this behavior on Linux (x86) as well as macOS (ARM) but not consistently.

On one macOS device it still work, although that might be due to some pre-commit caching going on. I did try to delete ~/.cache/pre-commit and re-install the hooks. But it still works for that machine, somehow.

Does anybody have any ideas what might be going wrong?

@ammar257ammar
Copy link

ammar257ammar commented Oct 21, 2024

I have been getting the same error since this morning! with the same error log above.

I also tried to delete ~/.cache/pre-commit and re-install the hooks, but that did not work. All other environments installation succeed but not biomejs/pre-commit

I am using MacOS

@Apakottur
Copy link

This error was fixed in #12, but was not yet released.

You can apply the fix manually locally until it's released:

repos:
  # ... other hooks
  - repo: https://github.com/biomejs/pre-commit
    rev: v0.5.0
    hooks:
      - id: biome-check
        additional_dependencies: ["@biomejs/biome@1.9.3"]
        files: "\\.(jsx?|tsx?|c(js|ts)|m(js|ts)|d\\.(ts|cts|mts)|css|svelte|vue|astro|graphql|gql)$"
        # Temporary fix until https://github.com/biomejs/pre-commit/pull/12 is released.
        language_version: lts

This fixed the error for me.

@gfringeli
Copy link
Author

Thanks @Apakottur for the information. lts did not work in my case, but specifying the latest node 22 release, i.e. language_version: 22.10.0 did.

@ammar257ammar
Copy link

Thanks for the fix, it worked for me as proposed. However, it is required to commit the changes to .pre-commit-config.yaml before I can make new commits which I don't want to have in my PRs. How long in your estimate it would take to release the change?

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

No branches or pull requests

3 participants