From 80643d63a8f8fe005786dc064e25bed02a28d9a7 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 16 Jan 2012 06:27:16 -0800 Subject: [PATCH] Detect empty $PATH environmental var Summary: By default, PHP-FMP (an alternate PHP FCGI SAPI) cleans the entire environment for child processes. This means we have no $PATH. This causes some confusing failures for reasons I don't fully understand. If you do these things: exec_manual('env'); exec_manual('export'); ...they show no $PATH, as expected. If you do this: exec_manual('echo $PATH'); ...it shows a path. And this works (i.e., it finds the executable): exec_manual('ls'); ...but this fails (it says "no ls in ((null))"): exec_manual('which ls'); So, basically, the sh -c process itself gets a default PATH somehow, but its children don't. I don't realllly get why this happens, but clearly an empty $PATH is a misconfiguration, and can easily be remedied. See discussion here: https://github.com/facebook/libphutil/issues/7 Test Plan: Applied patch to Centos6 + nginx + PHP-FPM machine, ran setup, the configuration issue was detected and I was given information on resolving it. Reviewers: btrahan, jungejason Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D1413 --- src/infrastructure/setup/PhabricatorSetup.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/infrastructure/setup/PhabricatorSetup.php b/src/infrastructure/setup/PhabricatorSetup.php index e24a18a98c..110ddb39c8 100644 --- a/src/infrastructure/setup/PhabricatorSetup.php +++ b/src/infrastructure/setup/PhabricatorSetup.php @@ -122,6 +122,26 @@ class PhabricatorSetup { "consequences of leaving it unconfigured.\n"); } + $path = getenv('PATH'); + if (empty($path)) { + self::writeFailure(); + self::write( + "Setup failure! The environmental \$PATH variable is empty. ". + "Phabricator needs to execute system commands like 'svn', 'git', ". + "'hg', and 'diff'. Set up your webserver so that it passes a valid ". + "\$PATH to the PHP process.\n\n"); + if (php_sapi_name() == 'fpm-fcgi') { + self::write( + "You're running php-fpm, so the easiest way to do this is to add ". + "this line to your php-fpm.conf:\n\n". + " env[PATH] = /usr/local/bin:/usr/bin:/bin\n\n". + "Then restart php-fpm.\n"); + } + return; + } else { + self::write(" okay \$PATH is nonempty.\n"); + } + self::write("[OKAY] Core configuration OKAY.\n"); self::writeHeader("REQUIRED PHP EXTENSIONS");