From bb9793019ca977cbc7b4a763e878cb98917da18b Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 2 Jun 2023 08:01:51 -0700 Subject: [PATCH] Expand PATH with /usr/local/bin Summary: ^ There is an issue whereas when Flipper Server is launched NOT from the terminal, it doesn't inherit the user's terminal `$PATH` variable. This causes a few different issues. This change tries to address that. Reviewed By: passy Differential Revision: D46392435 fbshipit-source-id: 6201a1749134db8c50eca8751af149737dce57d7 --- desktop/flipper-server/src/index.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/desktop/flipper-server/src/index.tsx b/desktop/flipper-server/src/index.tsx index 0bdd83876..29d462d97 100644 --- a/desktop/flipper-server/src/index.tsx +++ b/desktop/flipper-server/src/index.tsx @@ -17,6 +17,7 @@ import {initializeLogger} from './logger'; import fs from 'fs-extra'; import yargs from 'yargs'; import open from 'open'; +import os from 'os'; import {initCompanionEnv} from 'flipper-server-companion'; import { checkPortInUse, @@ -93,6 +94,16 @@ console.log( }`, ); +/** + * When running as a standlone app not run from the terminal, the process itself + * doesn't inherit the user's terminal PATH environment variable. + * The PATH, when NOT launched from terminal is `/usr/bin:/bin:/usr/sbin:/sbin` + * which is missing `/usr/local/bin`. + */ +if (os.platform() !== 'win32') { + process.env.PATH = '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'; +} + const rootPath = argv.bundler ? path.resolve(__dirname, '..', '..') : path.resolve(__dirname, '..'); // in pre packaged versions of the server, static is copied inside the package