Skip to content

openspec validate hangs when runnings as pre-commit hook #367

@greenkiwi

Description

@greenkiwi

We use pre-commit to ensure that our code is linted before committing.

https://pre-commit.com/

We have noticed that pre-commit hangs when it goes to run this check.

I wanted to run openspec validate there

repos:
  - repo: local
    hooks:
      - id: openspec-validate
        name: Validate OpenSpec
        language: script
        entry: openspec
        args:
          - "validate"
          - "--specs"
          - "--strict"
          - "--no-interactive"
        pass_filenames: false
        files: ^openspec/specs/

For some reason this hook just hangs. Running the command locally works - as does wrapping the call in a separate script:

#!/bin/sh
set -e
# Disable any potential interactive features
export CI=true
export OPENSPEC_NO_INTERACTIVE=1
# Close stdin and exec
exec openspec validate --specs --strict --no-interactive 0<&-

I've created a repo to help test this out:

https://github.com/greenkiwi/openspec-pre-commit-hook-issue

It has all the files and hooks.

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