From bfdce02689b734f368f6cd6791317ebb3d588079 Mon Sep 17 00:00:00 2001 From: Angelos Evripiotis Date: Wed, 3 Apr 2013 12:49:22 -0700 Subject: [PATCH] prepend path/to/phabricator/support/bin/ to $PATH Summary: It's sometimes necessary to specify the paths to individual binaries explicitly, e.g. a particular build of 'javelinsymbols' or a newer version of git than is installed on your shared system. By adding symlinks in the .../phabricator/support/bin/ directory you can now spell these out using the file system. Test Plan: Ran on local Ubuntu VM: .. add 'TEST' repo to diffusion .. .. visit 127.0.01/diffusion/TEST - see ok .. $ cd /opt $ sudo sh -c 'echo "exit 1" > badgit' $ sudo chmod +x /opt/badgit $ sudo mkdir goodgit $ sudo mv /usr/bin/git /opt/goodgit/ .. unset environment.append-paths .. .. visit 127.0.01/diffusion/TEST - see error 'git: not found' .. .. set environment.append-paths to /opt/goodgit/ .. .. visit 127.0.01/diffusion/TEST - see ok .. $ sudo ln -s /opt/badgit /usr/bin/git .. visit 127.0.01/diffusion/TEST - see error 'error #1' .. sudo ln -s /opt/goodgit/git web/phabricator/support/bin/git .. visit 127.0.01/diffusion/TEST - see ok .. .. unset environment.append-paths .. .. visit 127.0.01/diffusion/TEST - see ok .. $ sudo rm web/phabricator/support/bin/git .. visit 127.0.01/diffusion/TEST - see error 'error #1' .. $ sudo rm /usr/bin/git $ sudo mv /opt/goodgit/git /usr/bin/ .. visit 127.0.01/diffusion/TEST - see ok .. Note that 'DIRECTORY_SEPARATOR' was not used because apparently it's portable and ok to just use '/'. http://alanhogan.com/tips/php/directory-separator-not-necessary (I'm pretty new to PHP so looking for guidance :) Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2378 Differential Revision: https://secure.phabricator.com/D5561 --- src/infrastructure/env/PhabricatorEnv.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/infrastructure/env/PhabricatorEnv.php b/src/infrastructure/env/PhabricatorEnv.php index 394f5e33a6..1cad3d4f12 100644 --- a/src/infrastructure/env/PhabricatorEnv.php +++ b/src/infrastructure/env/PhabricatorEnv.php @@ -96,13 +96,17 @@ final class PhabricatorEnv { date_default_timezone_set('UTC'); } - // Append any paths to $PATH if we need to. - $paths = PhabricatorEnv::getEnvConfig('environment.append-paths'); - if (!empty($paths)) { - $current_env_path = getenv('PATH'); - $new_env_paths = implode(PATH_SEPARATOR, $paths); - putenv('PATH='.$current_env_path.PATH_SEPARATOR.$new_env_paths); + // Prepend '/support/bin' and append any paths to $PATH if we need to. + $env_path = getenv('PATH'); + $phabricator_path = dirname(phutil_get_library_root('phabricator')); + $support_path = $phabricator_path.'/support/bin'; + $env_path = $support_path.PATH_SEPARATOR.$env_path; + $append_dirs = PhabricatorEnv::getEnvConfig('environment.append-paths'); + if (!empty($append_dirs)) { + $append_path = implode(PATH_SEPARATOR, $append_dirs); + $env_path = $env_path.PATH_SEPARATOR.$append_path; } + putenv('PATH='.$env_path); PhabricatorEventEngine::initialize();