Skip to content

better error handling around ENOENT - #3954

Merged
iAmWillShepherd merged 5 commits into
masterfrom
better-error-handling-ENOENT
Feb 9, 2018
Merged

iAmWillShepherd merged 5 commits into
masterfrom
better-error-handling-ENOENT

Conversation

@shiftkey

@shiftkey shiftkey commented Feb 7, 2018

Copy link
Copy Markdown
Member

This lays the groundwork for resolving #3825 and #3882 by:

  • adding tracing when invoking shells for all OSes, not just Windows
  • handling the error event on a spawned child process (if we don't, this crashes the renderer)
  • display the error to the user rather than hiding it away

See for yourself (on Windows):

  • apply this patch to this branch
diff --git a/app/src/lib/shells/win32.ts b/app/src/lib/shells/win32.ts
index bd814808f..5ab2cb068 100644
--- a/app/src/lib/shells/win32.ts
+++ b/app/src/lib/shells/win32.ts
@@ -141,7 +141,9 @@ export function launch(
       cwd: path,
     })
   } else if (shell === Shell.Cmd) {
-    return spawn('START', ['cmd'], { shell: true, cwd: path })
+    const executable = `"C:\\Windows\\System32\\cmd.exe"`
+    log.info(`launching ${shell} at path: ${executable}`)
+    return spawn(executable, undefined, { shell: true, cwd: path })
   } else {
     return assertNever(shell, `Unknown shell: ${shell}`)
   }
  • run the app up
  • use Repository | Open in Command Prompt to trigger this error

Why this doesn't work as expected is what I'm currently wrestling with, but it'd be nice to get this into the next update so we have better diagnostics.

@shiftkey shiftkey added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Feb 7, 2018
@shiftkey shiftkey added this to the 1.1 milestone Feb 7, 2018
@shiftkey

shiftkey commented Feb 7, 2018

Copy link
Copy Markdown
Member Author

Moving this into 1.1 as I think it's a reasonably safe non-functional change.

@iAmWillShepherd iAmWillShepherd self-assigned this Feb 7, 2018
Comment thread app/src/lib/shells/linux.ts Outdated
shell: IFoundShell<Shell>,
path: string
): Promise<void> {
export function launch(shell: IFoundShell<Shell>, path: string): ChildProcess {

This comment was marked as spam.

This comment was marked as spam.

}

export async function launch(
export function launch(

This comment was marked as spam.

This comment was marked as spam.

Comment thread app/src/lib/shells/win32.ts Outdated
}
)
addErrorTracing(`PowerShell`, cp)
return spawn('START', ['powershell', '-NoExit', '-Command', psCommand], {

This comment was marked as spam.

This comment was marked as spam.

@shiftkey

shiftkey commented Feb 7, 2018

Copy link
Copy Markdown
Member Author

🍎

@iAmWillShepherd
iAmWillShepherd merged commit a991d2a into master Feb 9, 2018
@shiftkey
shiftkey deleted the better-error-handling-ENOENT branch February 16, 2018 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants