ulimit -n: Raise the Open-File Limit in CI
ulimit -n reports the maximum number of file descriptors a process may open, and raising it fixes the "too many open files" failures that hit large test runs.
Bundlers, watchers, and parallel test runners open many descriptors at once. When they exceed the soft limit, the job fails with EMFILE. ulimit -n shows and raises that limit.
What it does
ulimit is a shell builtin that reads and sets process resource limits. -n is the open-file-descriptor limit. Each limit has a soft value (the enforced one) and a hard ceiling; an unprivileged process may raise the soft value up to the hard value but cannot exceed the hard cap. -S and -H target each explicitly.
Common usage
ulimit -n # current soft limit
ulimit -Hn # hard ceiling
ulimit -n 65535 # raise soft limit for this shell + children
ulimit -a # show all resource limitsOptions
| Flag | What it does |
|---|---|
| -n [N] | Open files: show, or set the soft limit |
| -S / -H | Operate on the soft / hard limit |
| -u | Max user processes (nproc limit) |
| -a | Print every resource limit |
| -c | Core dump size limit |
In CI
When a job fails with "EMFILE: too many open files" or "Error: ENFILE", raise the limit early in the step: ulimit -n 65535 before launching the runner or test command (the limit is inherited by children). It applies only to the current shell and its descendants, so set it in the same step that runs the workload, not a prior one.
Common errors in CI
"ulimit: open files: cannot modify limit: Operation not permitted" means you tried to raise the soft limit above the hard ceiling; raise the hard limit first (needs root) or set it in /etc/security/limits.conf. The limit set in one CI step does not carry to the next step (each runs in a fresh shell), so set it where it is needed.