Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14012275
D10031.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D10031.diff
View Options
diff --git a/conf/default.conf.php b/conf/default.conf.php
--- a/conf/default.conf.php
+++ b/conf/default.conf.php
@@ -1085,6 +1085,7 @@
// the $PATH environment variable, for when these binaries are in non-standard
// locations.
'environment.append-paths' => array(),
+ 'environment.prepend-paths' => array(),
// -- Audit ---------------------------------------------------------- //
diff --git a/src/applications/config/check/PhabricatorSetupCheckBinaries.php b/src/applications/config/check/PhabricatorSetupCheckBinaries.php
--- a/src/applications/config/check/PhabricatorSetupCheckBinaries.php
+++ b/src/applications/config/check/PhabricatorSetupCheckBinaries.php
@@ -101,20 +101,22 @@
$preamble = pht(
"The '%s' binary could not be found. Set the webserver's %s ".
"environmental variable to include the directory where it resides, or ".
- "add that directory to '%s' in the Phabricator configuration.",
+ "add that directory to '%s' or '%s' in the Phabricator configuration.",
$bin,
'PATH',
- 'environment.append-paths');
+ 'environment.append-paths',
+ 'environment.prepend-paths');
} else {
$preamble = pht(
"The '%s' binary could not be found. Symlink it into '%s', or set the ".
"webserver's %s environmental variable to include the directory where ".
- "it resides, or add that directory to '%s' in the Phabricator ".
+ "it resides, or add that directory to '%s' or '%s' in the Phabricator ".
"configuration.",
$bin,
'phabricator/support/bin/',
'PATH',
- 'environment.append-paths');
+ 'environment.append-paths',
+ 'environment.prepend-paths');
}
$this->newIssue('bin.'.$bin)
@@ -123,7 +125,8 @@
->setSummary(
pht("The '%s' binary could not be located or executed.", $bin))
->setMessage($preamble.' '.$message)
- ->addPhabricatorConfig('environment.append-paths');
+ ->addPhabricatorConfig('environment.append-paths')
+ ->addPhabricatorConfig('environment.prepend-paths');
}
}
diff --git a/src/applications/config/check/PhabricatorSetupCheckImagemagick.php b/src/applications/config/check/PhabricatorSetupCheckImagemagick.php
--- a/src/applications/config/check/PhabricatorSetupCheckImagemagick.php
+++ b/src/applications/config/check/PhabricatorSetupCheckImagemagick.php
@@ -16,7 +16,8 @@
"'convert' binary not found or Imagemagick is not installed."))
->setMessage($message)
->addRelatedPhabricatorConfig('files.enable-imagemagick')
- ->addPhabricatorConfig('environment.append-paths');
+ ->addPhabricatorConfig('environment.append-paths')
+ ->addPhabricatorConfig('environment.prepend-paths');
}
}
}
diff --git a/src/applications/config/check/PhabricatorSetupCheckPath.php b/src/applications/config/check/PhabricatorSetupCheckPath.php
--- a/src/applications/config/check/PhabricatorSetupCheckPath.php
+++ b/src/applications/config/check/PhabricatorSetupCheckPath.php
@@ -3,7 +3,7 @@
final class PhabricatorSetupCheckPath extends PhabricatorSetupCheck {
protected function executeChecks() {
- // NOTE: We've already appended `environment.append-paths`, so we don't
+ // NOTE: We've already appended `environment.append-paths` and `environment.prepend-paths`, so we don't
// need to explicitly check for it.
$path = getenv('PATH');
@@ -26,6 +26,13 @@
->setMessage($message)
->addPhabricatorConfig('environment.append-paths');
+ $this
+ ->newIssue('config.environment.prepend-paths')
+ ->setName(pht('$PATH Not Set'))
+ ->setSummary($summary)
+ ->setMessage($message)
+ ->addPhabricatorConfig('environment.prepend-paths');
+
// Bail on checks below.
return;
}
@@ -117,7 +124,8 @@
"The user that the webserver runs as must be able to read all ".
"the directories in PATH in order to make use of them.",
$message))
- ->addPhabricatorConfig('environment.append-paths');
+ ->addPhabricatorConfig('environment.append-paths')
+ ->addPhabricatorConfig('environment.prepend-paths');
}
}
diff --git a/src/applications/config/check/PhabricatorSetupCheckPygment.php b/src/applications/config/check/PhabricatorSetupCheckPygment.php
--- a/src/applications/config/check/PhabricatorSetupCheckPygment.php
+++ b/src/applications/config/check/PhabricatorSetupCheckPygment.php
@@ -24,7 +24,8 @@
->setSummary($summary)
->setMessage($message)
->addRelatedPhabricatorConfig('pygments.enabled')
- ->addPhabricatorConfig('environment.append-paths');
+ ->addPhabricatorConfig('environment.append-paths')
+ ->addPhabricatorConfig('environment.prepend-paths');
}
}
}
diff --git a/src/applications/config/option/PhabricatorCoreConfigOptions.php b/src/applications/config/option/PhabricatorCoreConfigOptions.php
--- a/src/applications/config/option/PhabricatorCoreConfigOptions.php
+++ b/src/applications/config/option/PhabricatorCoreConfigOptions.php
@@ -141,6 +141,27 @@
->setLocked(true)
->addExample('/usr/local/bin', pht('Add One Path'))
->addExample("/usr/bin\n/usr/local/bin", pht('Add Multiple Paths')),
+ $this->newOption('environment.prepend-paths', 'list<string>', $paths)
+ ->setSummary(
+ pht('These paths get prepended to your \$PATH envrionment variable.'))
+ ->setDescription(
+ pht(
+ "Phabricator occasionally shells out to other binaries on the ".
+ "server. An example of this is the `pygmentize` command, used ".
+ "to syntax-highlight code written in languages other than PHP. ".
+ "By default, it is assumed that these binaries are in the \$PATH ".
+ "of the user running Phabricator (normally 'apache', 'httpd', or ".
+ "'nobody'). Here you can add extra directories to the \$PATH ".
+ "environment variable, for when these binaries are in ".
+ "non-standard locations.\n\n".
+ "Note that you can also put binaries in ".
+ "`phabricator/support/bin/` (for example, by symlinking them).\n\n".
+ "The current value of PATH after configuration is applied is:\n\n".
+ " lang=text\n".
+ " %s", $path))
+ ->setLocked(true)
+ ->addExample('/usr/local/bin', pht('Add One Path'))
+ ->addExample("/usr/bin\n/usr/local/bin", pht('Add Multiple Paths')),
$this->newOption('config.lock', 'set', array())
->setLocked(true)
->setDescription(pht('Additional configuration options to lock.')),
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
@@ -756,8 +756,9 @@
pht('Missing Binary %s', phutil_tag('tt', array(), $binary)))
->setNote(pht(
"Unable to find this binary in the webserver's PATH. You may ".
- "need to configure %s.",
- $this->getEnvConfigLink())));
+ "need to configure %s or %s.",
+ $this->getEnvConfigLinkAppend(),
+ $this->getEnvConfigLinkPrepend())));
} else {
$view->addItem(
id(new PHUIStatusItemView())
@@ -784,15 +785,26 @@
}
}
if (!$in_path) {
+ $dirs = PhabricatorEnv::getEnvConfig('environment.prepend-paths');
+ foreach ($dirs as $dir) {
+ if (Filesystem::isDescendant($path, $dir)) {
+ $in_path = true;
+ break;
+ }
+ }
+ }
+
+ if (!$in_path) {
$view->addItem(
id(new PHUIStatusItemView())
->setIcon(PHUIStatusItemView::ICON_WARNING, 'red')
->setTarget(
pht('Missing Binary %s', phutil_tag('tt', array(), $binary)))
->setNote(pht(
- 'Unable to find this binary in `environment.append-paths`. '.
- 'You need to configure %s and include %s.',
- $this->getEnvConfigLink(),
+ 'Unable to find this binary in `environment.append-paths` or `environment.prepend-paths`. '.
+ 'You need to configure %s or %s and include %s.',
+ $this->getEnvConfigLinkAppend(),
+ $this->getEnvConfigLinkPrepend(),
$path)));
}
}
@@ -1107,7 +1119,7 @@
return $mirror_list;
}
- private function getEnvConfigLink() {
+ private function getEnvConfigLinkAppend() {
$config_href = '/config/edit/environment.append-paths/';
return phutil_tag(
'a',
@@ -1117,4 +1129,13 @@
'environment.append-paths');
}
+ private function getEnvConfigLinkPrepend() {
+ $config_href = '/config/edit/environment.prepend-paths/';
+ return phutil_tag(
+ 'a',
+ array(
+ 'href' => $config_href,
+ ),
+ 'environment.prepend-paths');
+ }
}
diff --git a/src/infrastructure/env/PhabricatorEnv.php b/src/infrastructure/env/PhabricatorEnv.php
--- a/src/infrastructure/env/PhabricatorEnv.php
+++ b/src/infrastructure/env/PhabricatorEnv.php
@@ -96,16 +96,25 @@
date_default_timezone_set('UTC');
}
- // Prepend '/support/bin' and append any paths to $PATH if we need to.
+ // Prepend '/support/bin' and prepend/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;
}
+
+ $prepend_dirs = PhabricatorEnv::getEnvConfig('environment.prepend-paths');
+ if (!empty($prepend_dirs)) {
+ $prepend_path = implode(PATH_SEPARATOR, $prepend_dirs);
+ $env_path = $prepend_path.PATH_SEPARATOR.$env_path;
+ }
+
+
putenv('PATH='.$env_path);
// Write this back into $_ENV, too, so ExecFuture picks it up when creating
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 2, 10:36 AM (2 d, 11 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6721433
Default Alt Text
D10031.diff (10 KB)
Attached To
Mode
D10031: support for prepending paths to system PATH environment variable
Attached
Detach File
Event Timeline
Log In to Comment