@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

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

authored by

Angelos Evripiotis and committed by
epriestley
bfdce026 a13390a9

+10 -6
+10 -6
src/infrastructure/env/PhabricatorEnv.php
··· 96 96 date_default_timezone_set('UTC'); 97 97 } 98 98 99 - // Append any paths to $PATH if we need to. 100 - $paths = PhabricatorEnv::getEnvConfig('environment.append-paths'); 101 - if (!empty($paths)) { 102 - $current_env_path = getenv('PATH'); 103 - $new_env_paths = implode(PATH_SEPARATOR, $paths); 104 - putenv('PATH='.$current_env_path.PATH_SEPARATOR.$new_env_paths); 99 + // Prepend '/support/bin' and append any paths to $PATH if we need to. 100 + $env_path = getenv('PATH'); 101 + $phabricator_path = dirname(phutil_get_library_root('phabricator')); 102 + $support_path = $phabricator_path.'/support/bin'; 103 + $env_path = $support_path.PATH_SEPARATOR.$env_path; 104 + $append_dirs = PhabricatorEnv::getEnvConfig('environment.append-paths'); 105 + if (!empty($append_dirs)) { 106 + $append_path = implode(PATH_SEPARATOR, $append_dirs); 107 + $env_path = $env_path.PATH_SEPARATOR.$append_path; 105 108 } 109 + putenv('PATH='.$env_path); 106 110 107 111 PhabricatorEventEngine::initialize(); 108 112