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.

Using affected:build in CI yields spawnSync error

See original GitHub issue

Expected Behavior

When running affected:build in CI, Nx should build the affected apps.

Current Behavior

The affected:build command fails before running any tests.

Failure Information (for bugs)

Build output:

$ ./node_modules/.bin/nx affected:build --base=origin/master --prod --build-optimizer

>  NX   ERROR  There was a critical error when running your command

  spawnSync /bin/sh ENOBUFS

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: Job failed: command terminated with exit code 1

Steps to Reproduce

We are using FROM node:12 as our base docker image in CI.

Context

Please provide any relevant information about your setup:

  • version of Nx used: 8.5.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
MichaelKaadencommented, Apr 23, 2020

Hi,

today I ran into the same problem using nx affected in my Jenkins pipeline: Error: spawnSync /bin/sh ENOBUFS.

After some investigation, I saw that git ls-files --others --exclude-standard produced an output with a size of 11 MB because of Yarn’s .cache directory inside the workspace. Well, that’s definitely above rdp10’s PR.

After some thought, I found a very simple solution: git ls-files --others --exclude-standard ignores everything that is in your .gitignore file. So, to get rid of this error, it’s sufficient to put .cache inside your .gitignore file.

@vsavkin: Would perhaps be worth a hint in the documentation. 😉

Hope that helps.

Best wishes, Michael

2reactions
robinpellegrimscommented, Apr 26, 2020

Had the same issue today in my gitlab ci pipeline. Turned out my .gitignore file was ignored by my .dockerignore file, which made git ls-files --others --exclude-standard return the whole contents of node_modules… Removing .gitignore from the .dockerignore file solved it.

Thanks for pointing me in the right direction @MichaelKaaden.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handle Node.js spawnSync errors - Stack Overflow
In Node documentation regarding options.stdio it says. By default, the child's stdin, stdout, and stderr are redirected to corresponding subprocess.stdin, ...
Read more >
Child process | Node.js v19.3.0 Documentation
Node.js lexicographically sorts the env keys and uses the first one that ... spawnSync() function provides equivalent functionality in a synchronous manner ...
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