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

make error when run without access to /proc #3059

Open
jasonaowen opened this issue Aug 15, 2024 · 0 comments
Open

make error when run without access to /proc #3059

jasonaowen opened this issue Aug 15, 2024 · 0 comments

Comments

@jasonaowen
Copy link

  • Node Version: node = v20.16.0, npm = 10.8.1
  • Platform: Linux 6.8.0-40-generic x86_64
  • Module: re2
Verbose output (from npm or node-gyp):
npm error gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build', '--jobs', 0 ]
npm error make: the '-j' option requires a positive integer argument

When building a package using the systemd security option ProcSubset=pid, gyp sets the number of jobs to 0, which make does not accept.

I believe the relevant code is here:

node-gyp/lib/build.js

Lines 176 to 179 in e6f4ede

} else if (jobs.toUpperCase() === 'MAX') {
argv.push('--jobs')
argv.push(require('os').cpus().length)
}

The documentation for Node function os.cpus() says:

Returns an array of objects containing information about each logical CPU core. The array will be empty if no CPU information is available, such as if the /proc file system is unavailable.

This can be shown by getting the number of CPUs in a transient service unit:

$ node -e "console.log(require('node:os').cpus().length)"
16

$ sudo systemd-run -p ProcSubset=pid -t -- \
  node -e "console.log(require('node:os').cpus().length)"
0

In the event of os.cpus() not returning any information, I suggest that gyp should either default to some constant number of parallel jobs or let make run as many jobs as it wants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant