Closed stijnvn closed 2 months ago
Which particular distro of Linux are you on?
What is the result of:
getconf ARG_MAX
I'm on Pop!_OS and it's 2097152
for me.
That is the value we use to chunk the changed files into sets which fit into the command.
I could see it failing is if there is a file path that is so long that it alone, does not fit in a command but I think it would have to be really long which your paths do not seem to be that long. So maybe the command length limit is low?
I saw this issue on GitHub actions running ubuntu_latest. I could also reproduce it on a test server running Rocky Linux 9. On that server I also get 2097152
as result of getconf ARG_MAX
.
However I can run nx format
on my iMac without error. The result of getconf ARG_MAX
is 1048576
.
I did a more debugging. If I monkey patch getUnixTerminalSize()
in node_modules/nx/src/utils/chunkify.js
the command runs properly with a size smaller or equal than 131541
.
For me this works with node 16, but anything higher than that I get this issue.
The same issue on Gitlab CI.
Command nx format:check --base=XXX
sometimes fails without any output (just code 1
), but nx format:check --all
always work (but slower).
getconf ARG_MAX
> 2097152
After investigating a bit, I found that while ARG_MAX is indeed 2097152 on my laptop, it actually only works for chunks < than about 131k. This is because while 2097152 is the maximum length of an entire command, the length of a single argument is hardcoded in the kernel (in our case it's 131072).
In the nx/src/command-line/format.js
file, the command is executed via child_process.execSync
, which is turns will exec /bin/sh -c "${THE_COMMAND}"
so the command is considered as a single argument instead of having one argument per file.
I didn't find a way to get this value programmatically, so there are 2 ways to fix this:
child_process.spawnSync
instead of execSync
, it will use one arg per file instead of wrapping the command in a single arg.
chunkify.js
(which already falls back to 100k if getconf ARG_MAX
fails).Fixed with https://github.com/nrwl/nx/pull/21074
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
Running
nx format
on GitHub Actions fails with:Running
nx format:check
fails with a less clear error message:It seems that there are too many files to be checked.
Expected Behavior
nx format
should work with many files.Steps to Reproduce
nx format
on a branch with many changed filesNx Report
Operating System