phetsims / perennial

Maintenance tools that won't change with different versions of chipper checked out
MIT License
2 stars 5 forks source link

Error: spawn git ENOENT for missing repo in pull-all.js #220

Closed samreid closed 3 years ago

samreid commented 3 years ago

This is a specific subproblem from #206.

Error when running pull-all.js with a missing repo:

~/apache-document-root/main$ pull
events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: spawn git ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn git',
  path: 'git',
  spawnargs: [ 'pull', '--rebase' ]
}
~/apache-document-root/main$ clone-missing-repos.sh 
skiffle
Cloning into 'skiffle'...
remote: Enumerating objects: 36, done.
remote: Counting objects: 100% (36/36), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 36 (delta 13), reused 28 (delta 9), pack-reused 0
Unpacking objects: 100% (36/36), done.
Reinitialized existing Git repository in /Users/samreid/apache-document-root/main/skiffle/.git/
~/apache-document-root/main$ pull
~/apache-document-root/main$ 
zepumph commented 3 years ago

I was just bit by this for skiffle, so I committed https://github.com/phetsims/perennial/commit/6764b284fabc82bdaf0b9e9e722bf6873728214f, which fixes this issue, but only handles part of the work to be done over in your recommendation in https://github.com/phetsims/perennial/issues/206#issuecomment-793031078.

This is the error before I cloned skiffle after that commit:

 Michael ~/PHET/git
 $ pa
(node:35596) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:35596) UnhandledPromiseRejectionWarning: Error: git pull --rebase in skiffle failed with exit code -1 and stdout:

    at ChildProcess.<anonymous> (C:\Users\Michael\PHET\git\perennial\js\common\execute.js:76:15)
    at ChildProcess.emit (events.js:315:20)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
(node:35596) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function witho
ut a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the
 CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:35596) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will te
rminate the Node.js process with a non-zero exit code.

It could be further improved if we surround the execute commands in pull-all.js in a try catch and handle the rejections.

samreid commented 3 years ago

I added optional resolve support for process errors, and support it in the pull-all.js harness. You can test it by adding a fake repo name to active-repos.js and running pull-all.js. I see this:

~/apache-document-root/main$ pull
## fakeREPO
Error: spawn git ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn git',
  path: 'git',
  spawnargs: [ 'pull', '--rebase' ]
}

@zepumph can you please review?

zepumph commented 3 years ago

Excellent!