Skip to content

os.sysconf() call fails in highly restricted sandboxed environments (e.g., Cursor IDE) #3589

@MichaelRWolf

Description

@MichaelRWolf

Searches I tried in the issue tracker

  • os.sysconf
  • SC_ARG_MAX

Problem Description

The pre-commit tool is failing in highly secure, sandboxed execution environments, such as those used by the Cursor IDE agent. The sandbox intentionally blocks non-essential system calls for security reasons (like preventing sandbox escapes and host reconnaissance).

Specifically, the tool attempts to call os.sysconf() (or equivalent C library functions) to dynamically determine system limits, such as the maximum argument size (_SC_ARG_MAX). This system call is blocked by the sandbox, causing the hook execution to fail silently or with an unhandled exception in environments where system calls are filtered.

Error message from cursor chat

I can’t reliably run git commit for you here:
Your pre-commit hook calls os.sysconf('SC_ARG_MAX'), which is blocked in this sandbox, causing pre-commit (and thus git commit) to fail.
Please run this in your own shell (Cursor terminal / iTerm, etc.), where pre-commit can run normally:

Suggested Solution

To make pre-commit more robust in restricted environments, please consider adding a fallback mechanism to use a reasonable, hardcoded POSIX default (e.g., 4096 bytes) for maximum argument size if the dynamic os.sysconf() call fails or is unavailable. This would allow the tool to function without violating strict security models.

See _POSIX_SC_MAX (4096) as an safe mimum if os.gesysconf('SC_ARG_MAX') is blocked.

Sample config file

.pre-commit-config.yaml

repos:
  - repo: https://github.com/igorshubovych/markdownlint-cli
    rev: v0.39.0
    hooks:
      - id: markdownlint-fix

pre-commit --version

pre-commit 4.3.0

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