From 82f5e81cec2727013d3291907ddd04cc7ffd7a37 Mon Sep 17 00:00:00 2001 From: Dave Rael Date: Fri, 16 Oct 2015 04:24:57 -0600 Subject: [PATCH] Restore check on ATOM_HOME (undo db57479bf92474bf9bfb832c70a2c5c947238e8d) Check on ATOM_HOME is not superfluous - needed on Linux because of difference in inheriting environment variables between browser and render processes --- static/index.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/static/index.js b/static/index.js index 9d09bf060..167a87d8e 100644 --- a/static/index.js +++ b/static/index.js @@ -13,6 +13,11 @@ console.error('Unhandled promise rejection %o with error: %o', promise, error) }) + // Ensure ATOM_HOME is always set before anything else is required + // This is because of a difference in Linux not inherited between browser and render processes + // issue #5142 + setupAtomHome() + // Normalize to make sure drive letter case is consistent on Windows process.resourcesPath = path.normalize(process.resourcesPath) @@ -77,6 +82,24 @@ require('ipc').sendChannel('window-command', 'window:loaded') } + function setupAtomHome () { + if (!process.env.ATOM_HOME) { + var home + if (process.platform === 'win32') { + home = process.env.USERPROFILE + } else { + home = process.env.HOME + } + var atomHome = path.join(home, '.atom') + try { + atomHome = fs.realpathSync(atomHome) + } catch (error) { + // Ignore since the path might just not exist yet. + } + process.env.ATOM_HOME = atomHome + } + } + function setupCsonCache (cacheDir) { require('season').setCacheDir(path.join(cacheDir, 'cson')) }