code-complexity icon indicating copy to clipboard operation
code-complexity copied to clipboard

Error: spawnSync /bin/sh ENOBUFS

Open pipopotamasu opened this issue 4 months ago • 1 comments

I encountered Error: spawnSync /bin/sh ENOBUFS error when executing code-complexity. This is the error output.

node:internal/errors:932
  const err = new Error(message);
              ^
Error: Command failed: code-complexity . --since=2022-08-08 --format=json
<ref *1> Error: spawnSync /bin/sh ENOBUFS
    at Object.spawnSync (node:internal/child_process:1124:20)
    at spawnSync (node:child_process:876:24)
    at execSync (node:child_process:957:15)
    at GitHistory.executeGitLogCommand (/builds/developers/test-repo/node_modules/code-complexity/dist/src/lib/githistory/githistory.js:58:50)
    at GitHistory.buildHistory (/builds/developers/test-repo/node_modules/code-complexity/dist/src/lib/githistory/githistory.js:40:29)
    at new GitHistory (/builds/developers/test-repo/node_modules/code-complexity/dist/src/lib/githistory/githistory.js:16:29)
    at GitHistory.build (/builds/developers/test-repo/node_modules/code-complexity/dist/src/lib/githistory/githistory.js:12:16)
    at Statistics.compute (/builds/developers/test-repo/node_modules/code-complexity/dist/src/lib/statistics/statistics.js:14:49)
    at main (/builds/developers/test-repo/node_modules/code-complexity/dist/src/io/index.js:13:44) {
  errno: -105,
  code: 'ENOBUFS',
  syscall: 'spawnSync /bin/sh',
  path: '/bin/sh',
  spawnargs: [
    '-c',
    `git -C . log --follow --format='' --name-only --since="2022-08-08" '*'`
  ],

...

It looks like the buffer size is not enough when executing git log. Based on the assumption, this error can happen if the output of git log is too large.

pipopotamasu avatar Aug 15 '25 01:08 pipopotamasu

Hi there,

Sorry for the delay, I released a fix in an alpha version for the incoming v5. You can try it out here like this: npx code-complexity@alpha . --filter "**/*.ts" --sort=score -cs halstead

simonrenoult avatar Aug 21 '25 22:08 simonrenoult