Skip to content

The environment is too large for exec when using a window runner error being issued by find command

Description

Windows runner 16.4 errors out when running

From job log
Fetching changes...
++ mkdir -p ...
...
++ find <path>.git/modules -name index.lock -exec rm '{}' +
find: The environment is too large for exec().

From investigating it seems to be related to OS arg+env limits being hit for windows when the find cmd in gitlab-runner that tries to remove lock files as part of the initial setup.

Useful commands which helped expose this were

$ set | wc -c
$ set | wc -l
$ xargs --show-limits

and the search https://www.google.com/search?q=find+The+environment+is+too+large+for+exec&oq=find+The+environment+is+too+large+for+exec

Proposal

Currently cleanup of index.lock files is done by a single call to

find <path>.git/modules -name index.lock -exec rm '{}'

Request is to change this method of cleanup so that the limit is not reached.

A suggestion from the customer is that using

pre_get_sources_script = "for f in $(find $CI_PROJECT_DIR/.git -name index.lock); do rm $f; done"

in config.toml helps but sit then fails in the next stage.

Code area https://gitlab.com/gitlab-org/gitlab-runner/-/blob/main/shells/abstract.go#L487 but I'm uncertain as I can't see how this is converted to find ... exec so this may be well off-mark.

Links to related issues and merge requests / references

customer-premium Customer via support ticket ZD - (GitLab team member urls)

Edited by Alexander Strachan