ProcursusTeam / Procursus

Modern *OS Bootstrap
https://apt.procurs.us
BSD Zero Clause License
869 stars 126 forks source link

EPERM error NodeJS #689

Closed danieltroger closed 3 years ago

danieltroger commented 3 years ago

As mentioned here: https://github.com/parcel-bundler/parcel/discussions/6190#discussioncomment-664931

I'm getting this error trying to install parcel 2 with npm:

internal/child_process.js:402
    throw errnoException(err, 'spawn');
    ^

Error: spawn EPERM
    at ChildProcess.spawn (internal/child_process.js:402:11)
    at Object.spawn (child_process.js:553:9)
    at build ([stdin]:27:8)
    at preinstall ([stdin]:36:32)
    at [stdin]:9:7
    at ChildProcess.exithandler (child_process.js:315:5)
    at ChildProcess.emit (events.js:314:20)
    at maybeClose (internal/child_process.js:1047:16)
    at Socket.<anonymous> (internal/child_process.js:438:11)
    at Socket.emit (events.js:314:20) {
  errno: -1,
  code: 'EPERM',
  syscall: 'spawn'
}

To reproduce:

  1. Install nodejs and npm
  2. download this file (FYI: it is from https://github.com/parcel-bundler/parcel/issues/6167 but https://github.com/parcel-bundler/parcel/issues/6167 is not related with this issue)
  3. unzip the file
  4. go into the directory and run npm install
  5. if you get this error node_modules/.bin/node-gyp-build: 3: Syntax error: "(" unexpected do this: https://github.com/parcel-bundler/parcel/discussions/6190#discussioncomment-663981
  6. run npm install again and you should get the Error: spawn EPERM error. Running as root doesn't help.
TheRealKeto commented 3 years ago

Unfortunatly, this is an issue that kppless jailbreaks suffer from (e.g Chimera, Taurine). I suggest switching to a device that is vulnerable to checkra1n, as there are no issues there (at least for anything A10 and below).

sunflsks commented 3 years ago

I'll work on an EPERM patch for this. In the meantime, I suggest switching to non-kppless jailbreak like @TheRealKeto mentioned. There was also an issue opened here a few months back, with a substrate extension that managed to patch posix_spawn to allow executing shell scripts, but I'm not sure if it works.

danieltroger commented 3 years ago

Unfortunatly, this is an issue that kppless jailbreaks suffer from (e.g Chimera, Taurine).

That's too bad, I just updated my iPad 6 and iPhone X to iOS 14.3 and jailbroke with taurine - that's also what made me discover this new node version, as the one built by Sam Bingner (v12) barely ran.

I suggest switching to a device that is vulnerable to checkra1n, as there are no issues there (at least for anything A10 and below).

I have never gotten an answer on whether the iPad6 with A10 fusion works with the new blackbird/SEP patch in checkra1n on iOS 14? If you can confirm that it does I'll try to checkra1n it.

I'll work on an EPERM patch for this

That would be super appreciated! I really just wanted to be able to build and deploy scripts on the go from my main device which is an iPhone X running 14.3 on taurine.

There was also an issue opened here a few months back, with a substrate extension that managed to patch posix_spawn to allow executing shell scripts, but I'm not sure if it works.

The issue you're talking about seems to be https://github.com/ProcursusTeam/Procursus/issues/229, do you happen to know where I could get the dylibs to try them out?

demhademha commented 3 years ago
sunflsks commented 3 years ago

The issue you're talking about seems to be #229, do you happen to know where I could get the dylibs to try them out?

Sorry I'm a bit late to this, but I just checked, and that issue has a source file in it. You can just convert the %hookf into an MSHookFunction() call, compile it and link it with Substrate, and then inject the dylib into a process, and it should work. However, there were some issues with this, as mentioned in said thread (notably that DYLD_INSERT_LIBRARIES gets unset), so you might need to take a look at those as well. It also seems like it hooks posix_spawn(), which (as far as I know) is not used in NodeJS, as it uses fork() + execve() instead.

All of Apple's exec* wrappers eventually call the execve() C wrapper themselves (this is NOT the case on Glibc, on there it looks like each wrapper calls the syscall SYS_execve() independently, so don't bother testing on Linux), so hooking execve() may be a better option.

deatondg commented 3 years ago

To be clear, patching posix_spawn() did actually allow me to execve() shell scripts. The open source XNU implementation of execve() calls out to posix_spawn(), so I bet the implementation in iOS is similar.

However, I imagine this is fixed by the libiosexec1 thing recently pushed to the repo, so you should try this again.

danieltroger commented 3 years ago

However, I imagine this is fixed by the libiosexec1 thing recently pushed to the repo, so you should try this again.

Just installed and rebooted, still having the same issue unfortunately :(

CRKatri commented 3 years ago

NodeJS still has to be patched to use libiosexec

sunflsks commented 3 years ago

If #711 doesn't work for you, drop a comment and I'll reopen.

danieltroger commented 3 years ago

That's epic, thanks a lot for the quick fix! Will the package on the Procursus repo automatically update?

sunflsks commented 3 years ago

I forgot to bump the deb version in the Makefile, so it won't show up as an update for a few minutes. In the meantime though, you should just be able to reinstall the libuv1 package, and it should work.

danieltroger commented 3 years ago

Yesssss, it works! Thank you ❤️

(Installing parcel 2 unfortunately still fails on node-gyp not supporting iOS 🥲but this is a great step, now I can run so much more stuff 👌)

sunflsks commented 3 years ago

That's great to hear :)