mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-20 03:31:10 +01:00
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
This commit is contained in:
parent
a13390a919
commit
bfdce02689
1 changed files with 10 additions and 6 deletions
16
src/infrastructure/env/PhabricatorEnv.php
vendored
16
src/infrastructure/env/PhabricatorEnv.php
vendored
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue