From 138115f2a8752e6d7198fefce9e563d994e7b1e2 Mon Sep 17 00:00:00 2001 From: Landon Abney Date: Thu, 22 Feb 2018 12:21:21 -0800 Subject: [PATCH] :bug: Handle empty username If Atom is launched in a shell that is missing the `USER`/`USERNAME` environment variable it locks up due to an unhandled error from `crypto.update`. This switches to using Node.js's built in `os.userInfo()` method to retrieve the current user name, allowing Atom to complete initialization in this scenario. Fixes #16821. --- src/main-process/atom-application.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main-process/atom-application.js b/src/main-process/atom-application.js index 8f98ae4a5..43722e401 100644 --- a/src/main-process/atom-application.js +++ b/src/main-process/atom-application.js @@ -33,7 +33,7 @@ class AtomApplication extends EventEmitter { // Public: The entry point into the Atom application. static open (options) { if (!options.socketPath) { - const username = process.platform === 'win32' ? process.env.USERNAME : process.env.USER + const {username} = os.userInfo() // Lowercasing the ATOM_HOME to make sure that we don't get multiple sockets // on case-insensitive filesystems due to arbitrary case differences in paths. @@ -44,7 +44,7 @@ class AtomApplication extends EventEmitter { .update('|') .update(process.arch) .update('|') - .update(username) + .update(username || '') .update('|') .update(atomHomeUnique)