3 final class PhabricatorPathSetupCheck
extends PhabricatorSetupCheck
{
5 public function getDefaultGroup() {
6 return self
::GROUP_OTHER
;
9 protected function executeChecks() {
10 // NOTE: We've already appended `environment.append-paths`, so we don't
11 // need to explicitly check for it.
12 $path = getenv('PATH');
16 'The environmental variable %s is empty. Phabricator will not '.
17 'be able to execute some commands.',
21 "The environmental variable %s is empty. Phabricator needs to execute ".
22 "some system commands, like `%s`, `%s`, `%s`, and `%s`. To execute ".
23 "these commands, the binaries must be available in the webserver's ".
24 "%s. You can set additional paths in Phabricator configuration.",
33 ->newIssue('config.environment.append-paths')
34 ->setName(pht('%s Not Set', '$PATH'))
35 ->setSummary($summary)
36 ->setMessage($message)
37 ->addPhabricatorConfig('environment.append-paths');
39 // Bail on checks below.
43 // Users are remarkably industrious at misconfiguring software. Try to
44 // catch mistaken configuration of PATH.
46 $path_parts = explode(PATH_SEPARATOR
, $path);
48 foreach ($path_parts as $path_part) {
49 if (!strlen($path_part)) {
55 foreach (Filesystem
::walkToRoot($path_part) as $part) {
56 if (!Filesystem
::pathExists($part)) {
58 // Walk up so we can tell if this is a readability issue or not.
60 } else if (!is_dir(Filesystem
::resolvePath($part))) {
62 "The PATH component '%s' (which resolves as the absolute path ".
63 "'%s') is not usable because '%s' is not a directory.",
65 Filesystem
::resolvePath($path_part),
67 } else if (!is_readable($part)) {
69 "The PATH component '%s' (which resolves as the absolute path ".
70 "'%s') is not usable because '%s' is not readable.",
72 Filesystem
::resolvePath($path_part),
74 } else if ($not_exists) {
76 "The PATH component '%s' (which resolves as the absolute path ".
77 "'%s') is not usable because '%s' does not exist.",
79 Filesystem
::resolvePath($path_part),
82 // Everything seems good.
86 if ($message !== null) {
91 if ($message === null) {
92 if (!phutil_is_windows() && !@file_exists
($path_part.'/.')) {
94 "The PATH component '%s' (which resolves as the absolute path ".
95 "'%s') is not usable because it is not traversable (its '%s' ".
96 "permission bit is not set).",
98 Filesystem
::resolvePath($path_part),
103 if ($message !== null) {
104 $bad_paths[$path_part] = $message;
109 foreach ($bad_paths as $path_part => $message) {
110 $digest = substr(PhabricatorHash
::weakDigest($path_part), 0, 8);
113 ->newIssue('config.PATH.'.$digest)
114 ->setName(pht('%s Component Unusable', '$PATH'))
117 'A component of the configured PATH can not be used by '.
122 "The configured PATH includes a component which is not usable. ".
123 "Phabricator will be unable to find or execute binaries located ".
128 "The user that the webserver runs as must be able to read all ".
129 "the directories in PATH in order to make use of them.",
131 ->addPhabricatorConfig('environment.append-paths');