Skip to content
Latchkey

GitHub Actions "Argument list too long"

The OS caps the total size of a command line plus environment. Passing a huge expanded glob or list of files to a single command crosses that limit and fails with "Argument list too long".

What this error means

A run step fails with "Argument list too long" (E2BIG), typically when a shell glob expands to thousands of files passed to one command like rm, cp, or a linter.

github-actions
/usr/bin/find: cannot exec: Argument list too long
Error: Process completed with exit code 1.

Common causes

Glob expands to too many arguments

A pattern like rm dist/* expands to thousands of paths, exceeding the exec argument-size limit.

Oversized environment plus args

A large environment combined with a long argument list pushes the total over the limit.

How to fix it

Stream arguments instead of expanding inline

  1. Use find ... -exec or pipe into xargs to chunk arguments.
  2. Operate on a directory rather than expanding its contents.
  3. Reduce environment bloat where possible.
.github/workflows/ci.yml
- run: find dist -type f -name '*.log' -print0 | xargs -0 rm -f

How to prevent it

  • Pipe large file lists through xargs rather than inline globs.
  • Prefer directory-level operations over expanding every file.
  • Keep the environment lean on file-heavy steps.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →