Skip to content

pre-commit hook fails #1178

Description

@StephanFriedrichs

In version 2.54, the pre-commit hook is broken. It fails due to missing dependencies. Observed on pre-commit-4.6.0.

squawk: the "@squawk-cli/darwin-arm64" optional dependency was not installed.

I think this is because squawk-cli switched from a postinstall download script to platform-specific optional npm packages. Pre-commit's node environment does not install optional dependencies, so the binary is never available.

Reproduction steps:

  - repo: https://github.com/sbdchd/squawk
    rev: c3dc1e6ca2b5b6b4fafee8f3647cf8e0f99a9ae2  # frozen: v2.54.0
    hooks:
      - id: squawk
        name: squawk
        types: [sql]
pre-commit run -a squawk
squawk...................................................................Failed
- hook id: squawk
- exit code: 1

squawk: the "@squawk-cli/darwin-arm64" optional dependency was not installed.
This usually means your package manager skipped optional dependencies. Re-install with optional dependencies enabled (e.g. "npm install --include=optional").
squawk: the "@squawk-cli/darwin-arm64" optional dependency was not installed.
This usually means your package manager skipped optional dependencies. Re-install with optional dependencies enabled (e.g. "npm install --include=optional").

Attempted workaround: The problem is that just adding packages in additional_dependencies doesn't work because node checks the platform. However, we have a steup that requires Darwin as well as Linux:

    additional_dependencies:  # does not work!
      - "@squawk-cli/darwin-arm64@2.54.0"
      - "@squawk-cli/darwin-x64@2.54.0"
      - "@squawk-cli/linux-arm64@2.54.0"

Potential fix: Convert the pre-commit hook to language: rust. But this seems to require changes in Cargo.toml and I'm out of my depth there :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions