Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: spawn E2BIG when running postinstall scripts #6106

Open
douglasward opened this issue Feb 18, 2023 · 7 comments
Open

Error: spawn E2BIG when running postinstall scripts #6106

douglasward opened this issue Feb 18, 2023 · 7 comments

Comments

@douglasward
Copy link
Contributor

douglasward commented Feb 18, 2023

When upgrading from version 7.18.2 to 7.19.0, pnpm install errors out when running the postinstall scripts with the following error:

node:internal/child_process:413
    throw errnoException(err, 'spawn');
    ^
Error: spawn E2BIG
    at ChildProcess.spawn (node:internal/child_process:413:11)
    at spawn (node:child_process:713:9)
    at spawn (/usr/local/lib/node_modules/pnpm/dist/pnpm.cjs:104514:19)
    at runCmd_ (/usr/local/lib/node_modules/pnpm/dist/pnpm.cjs:117817:20)
    at /usr/local/lib/node_modules/pnpm/dist/pnpm.cjs:117761:11
    at processTicksAndRejections (node:internal/process/task_queues:78:11) {
  errno: -7,
  code: 'E2BIG',
  syscall: 'spawn'
}

It doesn't seem to matter which postinstall script is run, any from any dependency or our own one will suffice.

Our .npmrc file is as follows

node-linker=hoisted
shared-workspace-lockfile = false

We need node-linker=hoisted as we have some angular projects in our mono-repo. Unsetting this seems to fix the problem but breaks the application builds.

These to pull requests seem that they might be related (included in the 7.19 release):

pnpm version: 7.19.0 and upwards

Additional information:

  • node -v prints: 16.17.1
  • Windows, macOS, or Linux?: Tested on MacOS and on linux (Linux e545ebd99b57 4.19.0-17-amd64 #1 SMP Debian 4.19.194-1 (2021-06-10) x86_64 x86_64 x86_64 GNU/Linux)
@await-ovo
Copy link
Member

await-ovo commented Feb 20, 2023

Could you provide a minimal repo to reproduce this issue, I just tried it with the following project:

// packages/foo/package.json
{
  "name": "@pkg/foo",
  "dependencies": {
    "got": "^12.5.3",
    "ava": "^5.2.0",
    "prisma": "latest",
    "ts-node": "latest"
  }
}
// packages/bar/package.json
{
  "name": "@pkg/bar",
  "dependencies": {
    "prisma": "latest"
  }
}

// .npmrc
node-linker=hoisted
shared-workspace-lockfile=false

seems postinstall works find on pnpm v7.27.0:

image

@douglasward
Copy link
Contributor Author

yes, I've managed to boil it down to a lock file with the following packages:

{
  "name": "test",
  "devDependencies": {
    "@angular-devkit/build-angular": "^13.3.0",
    "@angular-devkit/core": "^13.3.0",
    "@angular/cli": "^13.3.0",
    "@angular/compiler-cli": "^13.3.0",
    "@nguniversal/builders": "^13.1.0",
    "jest": "^27.4.7",
    "jest-preset-angular": "^11.1.1"
  }
}

I also noticed that I can only reproduce it on linux, not on macOS.

I have attached a minimal repo to reproduce. If you use the Dockerfile to build an image it will throw the error, e.g. with docker build -t pnpm .

pnpm.zip

@douglasward
Copy link
Contributor Author

My colleague can reproduce it on his linux machine just with

"@angular-devkit/build-angular": "^13.3.0",
"@angular-devkit/core": "^13.3.0",

and no lockfile

@VeselyT
Copy link

VeselyT commented May 19, 2023

This seems to be caused by PATH environment variable (generated somewhere in npm-lifecycle package I think) that contains paths to all .bin folders in all nested node_modules?

It seems to be caused by this parameter that contains all those paths

extraBinPaths: opts.extraBinPaths ?? [],
(in our case about 3500 entries). Those paths look like this
image

Hope this will help to fix this issue.

@particle4dev
Copy link

@zkochan any update on this issue?

@tomikpik
Copy link

tomikpik commented Sep 7, 2023

+1 for this, it affects our production workload :(((( Could you please take a look at it?

@LuckaFEL
Copy link

Adding my vote for this. It's causing some serious disruptions in our production workflow. Mind giving it a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Priority
Development

No branches or pull requests

6 participants