Page MenuHomePhabricator

CLI scripts do not detect execution with bad SAPI binary (like `fcgi` instead of `cli` under cPanel)
Open, WishlistPublic

Description

While running following commands

./bin/storage upgrade
./bin/phd log --id 2670
or any other bin command system throwing me this stacktrace

[2017-05-19 09:48:37] EXCEPTION: (RuntimeException) Use of undefined constant STDOUT - assumed 'STDOUT' at [<phutil>/src/error/PhutilErrorHandler.php:221]
arcanist(head=master, ref.master=a59cfca5f190), phabricator(head=master, ref.master=7e46d7ab6a6b), phutil(head=master, ref.master=a900d7b63e95)
  #0 PhutilErrorHandler::handleError(integer, string, string, integer, array) called at [<phutil>/src/console/PhutilConsoleServer.php:30]
  #1 PhutilConsoleServer::handleMessage(PhutilConsoleMessage) called at [<phutil>/src/console/PhutilConsole.php:204]
  #2 PhutilConsole::writeMessage(PhutilConsoleMessage) called at [<phutil>/src/console/PhutilConsole.php:187]
  #3 PhutilConsole::writeTextMessage(string, array) called at [<phutil>/src/console/PhutilConsole.php:143]
  #4 PhutilConsole::writeOut(string, string) called at [<phabricator>/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php:160]
  #5 PhabricatorStorageManagementWorkflow::doAdjustSchemata(PhabricatorStorageManagementAPI, boolean) called at [<phabricator>/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php:139]
  #6 PhabricatorStorageManagementWorkflow::adjustSchemata(PhabricatorStorageManagementAPI, boolean) called at [<phabricator>/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementUpgradeWorkflow.php:97]
  #7 PhabricatorStorageManagementUpgradeWorkflow::didExecute(PhutilArgumentParser) called at [<phabricator>/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php:107]
  #8 PhabricatorStorageManagementWorkflow::execute(PhutilArgumentParser) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:441]
  #9 PhutilArgumentParser::parseWorkflowsFull(array) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:333]
  #10 PhutilArgumentParser::parseWorkflows(array) called at [<phabricator>/scripts/sql/manage_storage.php:248]

Event Timeline

Can you show me the output of this command?

$ /usr/bin/env php -v

Here's an example of what I'm after (your output probably will not look exactly like this):

epriestley@orbital ~/dev/phabricator $ /usr/bin/env php -v
PHP 7.1.2 (cli) (built: Feb 23 2017 10:02:49) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.2, Copyright (c) 1999-2017, by Zend Technologies
ea-php-cli Copyright 2016 cPanel, Inc.
PHP 5.6.30 (cgi-fcgi) (built: May 17 2017 20:27:47)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with the ionCube PHP Loader v4.7.5, Copyright (c) 2002-2014, by ionCube Ltd., and
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

Your system has php-fcgi installed on the CLI (note cgi-fcgi in the output). This is incorrect. Replace this binary with a php-cli SAPI binary.

We'll add a setup warning to detect this.

See also T2383.

epriestley renamed this task from Throwing error while running bin command to CLI scripts do not detect execution with bad SAPI binary (like `fcgi` instead of `cli` under cPanel).May 19 2017, 12:35 PM
epriestley triaged this task as Wishlist priority.
epriestley edited projects, added Setup; removed Bug Report.

Now i have changed that

PHP 5.6.30 (cli) (built: May 17 2017 20:27:43) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with the ionCube PHP Loader v4.7.5, Copyright (c) 2002-2014, by ionCube Ltd., and
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

it still throwing

2017-05-29 08:50:01] EXCEPTION: (RuntimeException) Use of undefined constant STDIN - assumed 'STDIN' at [<phutil>/src/error/PhutilErrorHandler.php:221]
arcanist(head=master, ref.master=a59cfca5f190), phabricator(head=master, ref.master=7e46d7ab6a6b), phutil(head=master, ref.master=a900d7b63e95)
  #0 PhutilErrorHandler::handleError(integer, string, string, integer, array) called at [<phutil>/src/future/exec/PhutilExecPassthru.php:65]
  #1 PhutilExecPassthru::execute() called at [<phutil>/src/future/exec/execx.php:50]
  #2 phutil_passthru(string, PhutilCommandString) called at [<phabricator>/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementDumpWorkflow.php:150]
  #3 PhabricatorStorageManagementDumpWorkflow::didExecute(PhutilArgumentParser) called at [<phabricator>/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php:107]
  #4 PhabricatorStorageManagementWorkflow::execute(PhutilArgumentParser) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:441]
  #5 PhutilArgumentParser::parseWorkflowsFull(array) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:333]
  #6 PhutilArgumentParser::parseWorkflows(array) called at [<phabricator>/scripts/sql/manage_storage.php:248]
ERROR: Phabricator backup interrupted. Cleaning up temporary directory "/home/varanet/dev.varaunited.net/phabricator/tmp/phabbackup.TEMP.3SOUXFfs"

while creating backup

If you believe this is not an issue with a bad SAPI binary, please file a new bug report including reproduction steps I can follow to reproduce the issue (see Providing Reproduction Steps for guidance).

I believe it is overwhelmingly likely that this is a configuration problem with your system, and that you will be unable to arrive at a set of reproduction steps which don't involve overwriting the cli SAPI binary with the fcgi SAPI binary.