question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error: Error: spawnSync git ENOBUFS

See original GitHub issue

Small reproduction:

  1. Create an empty folder with only one file: package.json

    {
      "name": "rw",
      "dependencies": {
        "react-window": "1.8.5"
      }
    }
    
  2. Make some changes inside node_modules/react-window/dist files

  3. npx patch-package react-window

  4. If fails with error below:

[17:05:40] brunolemos:rw $ patch-package react-window
patch-package 6.1.2
• Creating temporary folder
• Installing react-window@1.8.5 with yarn
• Diffing your files with clean files

{
  error: Error: spawnSync git ENOBUFS
      at Object.spawnSync (internal/child_process.js:1041:20)
      at Object.spawnSync (child_process.js:607:24)
      at Function.spawnSync [as sync] (/usr/local/lib/node_modules/patch-package/node_modules/cross-spawn/index.js:26:23)
      at Object.exports.spawnSafeSync (/usr/local/lib/node_modules/patch-package/dist/spawnSafe.js:10:32)
      at git (/usr/local/lib/node_modules/patch-package/dist/makePatch.js:73:32)
      at Object.makePatch (/usr/local/lib/node_modules/patch-package/dist/makePatch.js:104:26)
      at /usr/local/lib/node_modules/patch-package/dist/index.js:48:25
      at Array.forEach (<anonymous>)
      at Object.<anonymous> (/usr/local/lib/node_modules/patch-package/dist/index.js:47:22)
      at Module._compile (internal/modules/cjs/loader.js:868:30) {
    errno: 'ENOBUFS',
    code: 'ENOBUFS',
    syscall: 'spawnSync git',
    path: 'git',
    spawnargs: [
      'diff',
      '--cached',
      '--no-color',
      '--ignore-space-at-eol',
      '--no-ext-diff'
    ]
  },
  status: null,
  signal: 'SIGTERM',
  output: [
    null,
    <Buffer 64 69 66 66 20 2d 2d 67 69 74 20 61 2f 6e 6f 64 65 5f 6d 6f 64 75 6c 65 73 2f 72 65 61 63 74 2d 77 69 6e 64 6f 77 2f 64 69 73 74 2f 69 6e 64 65 78 2d ... 1056718 more bytes>,
    <Buffer >
  ],
  pid: 79859,
  stdout: <Buffer 64 69 66 66 20 2d 2d 67 69 74 20 61 2f 6e 6f 64 65 5f 6d 6f 64 75 6c 65 73 2f 72 65 61 63 74 2d 77 69 6e 64 6f 77 2f 64 69 73 74 2f 69 6e 64 65 78 2d ... 1056718 more bytes>,
  stderr: <Buffer >
}

/usr/local/lib/node_modules/patch-package/dist/makePatch.js:150
        throw e;
        ^
{
  error: Error: spawnSync git ENOBUFS
      at Object.spawnSync (internal/child_process.js:1041:20)
      at Object.spawnSync (child_process.js:607:24)
      at Function.spawnSync [as sync] (/usr/local/lib/node_modules/patch-package/node_modules/cross-spawn/index.js:26:23)
      at Object.exports.spawnSafeSync (/usr/local/lib/node_modules/patch-package/dist/spawnSafe.js:10:32)
      at git (/usr/local/lib/node_modules/patch-package/dist/makePatch.js:73:32)
      at Object.makePatch (/usr/local/lib/node_modules/patch-package/dist/makePatch.js:104:26)
      at /usr/local/lib/node_modules/patch-package/dist/index.js:48:25
      at Array.forEach (<anonymous>)
      at Object.<anonymous> (/usr/local/lib/node_modules/patch-package/dist/index.js:47:22)
      at Module._compile (internal/modules/cjs/loader.js:868:30) {
    errno: 'ENOBUFS',
    code: 'ENOBUFS',
    syscall: 'spawnSync git',
    path: 'git',
    spawnargs: [
      'diff',
      '--cached',
      '--no-color',
      '--ignore-space-at-eol',
      '--no-ext-diff'
    ]
  },
  status: null,
  signal: 'SIGTERM',
  output: [
    null,
    <Buffer 64 69 66 66 20 2d 2d 67 69 74 20 61 2f 6e 6f 64 65 5f 6d 6f 64 75 6c 65 73 2f 72 65 61 63 74 2d 77 69 6e 64 6f 77 2f 64 69 73 74 2f 69 6e 64 65 78 2d ... 1056718 more bytes>,
    <Buffer >
  ],
  pid: 79859,
  stdout: <Buffer 64 69 66 66 20 2d 2d 67 69 74 20 61 2f 6e 6f 64 65 5f 6d 6f 64 75 6c 65 73 2f 72 65 61 63 74 2d 77 69 6e 64 6f 77 2f 64 69 73 74 2f 69 6e 64 65 78 2d ... 1056718 more bytes>,
  stderr: <Buffer >
}
[17:05:44] brunolemos:rw $ 

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:23 (3 by maintainers)

github_iconTop GitHub Comments

67reactions
SudoPlzcommented, Feb 27, 2020

@alepri51 I temporarily worked around it and managed to create my patch by going to:

⁨node_modules⁩/patch-package⁩/dist⁩/makePatch.js line 108, specifically in this code:

return spawnSafe_1.spawnSafeSync("git", args, {
                cwd: tmpRepo.name,
                env: { HOME: tmpRepo.name },
            });

and added an extra option called maxBuffer to increase the buffer size to 100mb (it was 1 mb by default which is too low)

now the code looks like this:

return spawnSafe_1.spawnSafeSync("git", args, {
                cwd: tmpRepo.name,
                env: { HOME: tmpRepo.name },
                maxBuffer: 1024 * 1024 * 100
            });

and my patch was created successfully. I hope that helps someone.

56reactions
curio77commented, Mar 8, 2020

Thank you, this helped. So we now need to patch-package patch-package? 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

spawnSync /bin/sh ENOBUFS - Stack Overflow
Error "spawnSync /bin/sh ENOBUFS" spawns in my NodeJs application non-systematically while executing the following line : child_process.
Read more >
Troubleshooting | Lerna
Error : spawnSync /bin/sh ENOBUFS during ImportCommand.execute ... lerna ERR! execute Error: Command failed: git am -3 lerna ERR! execute error: Failed to ......
Read more >
node_modules 源码修改及团队版本管理新手踩坑指南
4.常见报错解决. 1.error: Error: spawnSync git ENOBUFS. 参考GitHub issue error: Error: spawnSync git ENOBUFS. 通过配置maxBuffer 解决,例子如下
Read more >
Developers - Patch react-native 0.59.9 failed - - Bountysource
Below is the error log if not exclude: ... error: Error: spawnSync git ENOBUFS at Object. ... error: Error: spawnSync git ENOBUFS at...
Read more >
Deploying 'dydxprotocol / solo' results "Error: spawnSync /bin ...
Is that something in the host that results with the ENOBUFS? Is that something in the solidity compiler? Compiling ./contracts/testing/TokenC.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found