Page MenuHomePhabricator

./bin/celerity map, ./scripts/celerity/generate_sprites.php - Attempt to connect to root@localhost failed with error #2002: No such file or directory
Closed, InvalidPublic

Description

Whenever I try to execute ./scripts/celerity/generate_sprites.php or ./bin/celerity map on my local repository, I get following error message:

# ./scripts/celerity/generate_sprites.php
[2016-11-15 19:39:06] EXCEPTION: (AphrontConnectionQueryException) Attempt to connect to root@localhost failed with error #2002: No such file or directory. at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:343]
arcanist(head=stable, ref.stable=e17fe43ca3fe, custom=1), phabricator(head=fc71a7e92dc26e0d93ec33d709391411d2bcd827), phutil(head=b10adc2e3f8692b81eeadf6765e89651a95f1516)
  #0 AphrontBaseMySQLDatabaseConnection::throwConnectionException(integer, string, string, string) called at [<phutil>/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php:76]
  #1 AphrontMySQLiDatabaseConnection::connect() called at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:101]
  #2 AphrontBaseMySQLDatabaseConnection::establishConnection() called at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:124]
  #3 AphrontBaseMySQLDatabaseConnection::requireConnection() called at [<phutil>/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php:15]
  #4 AphrontMySQLiDatabaseConnection::escapeBinaryString(string) called at [<phutil>/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php:11]
  #5 AphrontMySQLiDatabaseConnection::escapeUTF8String(string) called at [<phutil>/src/xsprintf/qsprintf.php:178]
  #6 xsprintf_query(AphrontMySQLiDatabaseConnection, string, integer, string, integer) called at [<phutil>/src/xsprintf/xsprintf.php:70]
  #7 xsprintf(string, AphrontMySQLiDatabaseConnection, array) called at [<phutil>/src/xsprintf/qsprintf.php:64]
  #8 qsprintf(AphrontMySQLiDatabaseConnection, string, string, string, string) called at [<phutil>/src/xsprintf/queryfx.php:5]
  #9 queryfx(AphrontMySQLiDatabaseConnection, string, string, string, string) called at [<phutil>/src/xsprintf/queryfx.php:13]
  #10 queryfx_all(AphrontMySQLiDatabaseConnection, string, string, string, string) called at [<phutil>/src/aphront/storage/connection/AphrontDatabaseConnection.php:52]
  #11 AphrontDatabaseConnection::queryData(string, string, string, string) called at [<phabricator>/src/infrastructure/storage/lisk/LiskDAO.php:535]
  #12 LiskDAO::loadRawDataWhere(string, string) called at [<phabricator>/src/infrastructure/storage/lisk/LiskDAO.php:476]
  #13 LiskDAO::loadAllWhere(string, string) called at [<phabricator>/src/infrastructure/env/PhabricatorConfigDatabaseSource.php:18]
  #14 PhabricatorConfigDatabaseSource::loadConfig(string) called at [<phabricator>/src/infrastructure/env/PhabricatorConfigDatabaseSource.php:7]
  #15 PhabricatorConfigDatabaseSource::__construct(string) called at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:238]
  #16 PhabricatorEnv::buildConfigurationSourceStack(boolean) called at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:95]
  #17 PhabricatorEnv::initializeCommonEnvironment(boolean) called at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:75]
  #18 PhabricatorEnv::initializeScriptEnvironment(boolean) called at [<phabricator>/scripts/init/lib.php:22]
  #19 init_phabricator_script(array) called at [<phabricator>/scripts/init/init-script.php:9]
  #20 require_once(string) called at [<phabricator>/scripts/__init_script__.php:3]
  #21 require_once(string) called at [<phabricator>/scripts/celerity/generate_sprites.php:4]

The issue happens without any modifications to the libphutil or Phabricator source-code (see version information above).

Event Timeline

epriestley added a subscriber: epriestley.

I can't reproduce this. Here's what I did:

  • Ran bin/celerity map.

I got this output:

epriestley@orbital ~/dev/phabricator $ ./bin/celerity map
Rebuilding 3 resource source(s).
Rebuilding resource source "phabricator" (CelerityPhabricatorResources)...
Found 135 binary resources.
Found 386 text resources.
...

Before we can accept this report upstream, we need information that allows us to reproduce it (see Contributing Bug Reports and Providing Reproduction Steps).

To move forward, provide additional information so that this report contains complete reproduction instructions we can use in a clean, local environment to reproduce the issue. Anyone should be able to follow the instructions you provide to reliably reproduce the problem you're encountering.

If we don't receive this information within a few days, we'll close this report as invalid.

I assume you have a MySQL server running on your machine? Thus the connection can be successfully established?

The following hack works around the issue:

diff --git a/scripts/celerity/generate_sprites.php b/scripts/celerity/generate_sprites.php
index ccdd194..094a733 100755
--- a/scripts/celerity/generate_sprites.php
+++ b/scripts/celerity/generate_sprites.php
@@ -1,7 +1,12 @@
 #!/usr/bin/env php
 <?php

-require_once dirname(dirname(__FILE__)).'/__init_script__.php';
+require_once dirname(dirname(__FILE__)).'/init/lib.php';
+
+init_phabricator_script(
+  array(
+    'config.optional' => true,
+  ));

 $args = new PhutilArgumentParser($argv);
 $args->setTagline(pht('regenerate CSS sprite sheets'));
diff --git a/scripts/setup/manage_celerity.php b/scripts/setup/manage_celerity.php
index bcda635..65f875f 100755
--- a/scripts/setup/manage_celerity.php
+++ b/scripts/setup/manage_celerity.php
@@ -1,8 +1,12 @@
 #!/usr/bin/env php
 <?php

-$root = dirname(dirname(dirname(__FILE__)));
-require_once $root.'/scripts/__init_script__.php';
+require_once dirname(dirname(__FILE__)).'/init/lib.php';
+
+init_phabricator_script(
+  array(
+    'config.optional' => true,
+  ));

 $args = new PhutilArgumentParser($argv);
 $args->setTagline(pht('manage celerity'));

I'm happy to work with you to answer questions about my local environment and try to narrow down what's different, but we charge for this because it's very time consuming and often only helps one user. See Consulting for details.

Complete steps for reproduction on my system:

$ git clone -b stable https://github.com/phacility/arcanist.git
Cloning into 'arcanist'...
remote: Counting objects: 17550, done.
remote: Total 17550 (delta 0), reused 0 (delta 0), pack-reused 17550
Receiving objects: 100% (17550/17550), 6.45 MiB | 1.42 MiB/s, done.
Resolving deltas: 100% (10824/10824), done.
$ git clone -b stable https://github.com/phacility/libphutil.git
Cloning into 'libphutil'...
remote: Counting objects: 14449, done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 14449 (delta 2), reused 0 (delta 0), pack-reused 14434
Receiving objects: 100% (14449/14449), 7.85 MiB | 3.50 MiB/s, done.
Resolving deltas: 100% (8528/8528), done.
$ git clone -b stable https://github.com/phacility/phabricator.git
Cloning into 'phabricator'...
remote: Counting objects: 216912, done.
remote: Compressing objects: 100% (708/708), done.
remote: Total 216912 (delta 323), reused 0 (delta 0), pack-reused 216200
Receiving objects: 100% (216912/216912), 118.31 MiB | 10.88 MiB/s, done.
Resolving deltas: 100% (144506/144506), done.
$ cd phabricator/
$ ./scripts/celerity/generate_sprites.php
[2016-11-15 19:58:29] EXCEPTION: (AphrontConnectionQueryException) Attempt to connect to root@localhost failed with error #2002: No such file or directory. at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:343]
arcanist(head=stable, ref.stable=e17fe43ca3fe), phabricator(head=stable, ref.stable=fc71a7e92dc2), phutil(head=stable, ref.stable=b10adc2e3f86)
  #0 AphrontBaseMySQLDatabaseConnection::throwConnectionException(integer, string, string, string) called at [<phutil>/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php:76]
  #1 AphrontMySQLiDatabaseConnection::connect() called at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:101]
  #2 AphrontBaseMySQLDatabaseConnection::establishConnection() called at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:124]
  #3 AphrontBaseMySQLDatabaseConnection::requireConnection() called at [<phutil>/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php:15]
  #4 AphrontMySQLiDatabaseConnection::escapeBinaryString(string) called at [<phutil>/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php:11]
  #5 AphrontMySQLiDatabaseConnection::escapeUTF8String(string) called at [<phutil>/src/xsprintf/qsprintf.php:178]
  #6 xsprintf_query(AphrontMySQLiDatabaseConnection, string, integer, string, integer) called at [<phutil>/src/xsprintf/xsprintf.php:70]
  #7 xsprintf(string, AphrontMySQLiDatabaseConnection, array) called at [<phutil>/src/xsprintf/qsprintf.php:64]
  #8 qsprintf(AphrontMySQLiDatabaseConnection, string, string, string, string) called at [<phutil>/src/xsprintf/queryfx.php:5]
  #9 queryfx(AphrontMySQLiDatabaseConnection, string, string, string, string) called at [<phutil>/src/xsprintf/queryfx.php:13]
  #10 queryfx_all(AphrontMySQLiDatabaseConnection, string, string, string, string) called at [<phutil>/src/aphront/storage/connection/AphrontDatabaseConnection.php:52]
  #11 AphrontDatabaseConnection::queryData(string, string, string, string) called at [<phabricator>/src/infrastructure/storage/lisk/LiskDAO.php:535]
  #12 LiskDAO::loadRawDataWhere(string, string) called at [<phabricator>/src/infrastructure/storage/lisk/LiskDAO.php:476]
  #13 LiskDAO::loadAllWhere(string, string) called at [<phabricator>/src/infrastructure/env/PhabricatorConfigDatabaseSource.php:18]
  #14 PhabricatorConfigDatabaseSource::loadConfig(string) called at [<phabricator>/src/infrastructure/env/PhabricatorConfigDatabaseSource.php:7]
  #15 PhabricatorConfigDatabaseSource::__construct(string) called at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:238]
  #16 PhabricatorEnv::buildConfigurationSourceStack(boolean) called at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:95]
  #17 PhabricatorEnv::initializeCommonEnvironment(boolean) called at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:75]
  #18 PhabricatorEnv::initializeScriptEnvironment(boolean) called at [<phabricator>/scripts/init/lib.php:22]
  #19 init_phabricator_script(array) called at [<phabricator>/scripts/init/init-script.php:9]
  #20 require_once(string) called at [<phabricator>/scripts/__init_script__.php:3]
  #21 require_once(string) called at [<phabricator>/scripts/celerity/generate_sprites.php:4]
$ php --version
PHP 7.0.12-1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.12-1, Copyright (c) 1999-2016, by Zend Technologies
$ php5 ./scripts/celerity/generate_sprites.php
[2016-11-15 20:02:04] EXCEPTION: (AphrontConnectionQueryException) Attempt to connect to root@localhost failed with error #2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2). at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:343]
arcanist(head=stable, ref.stable=e17fe43ca3fe), phabricator(head=stable, ref.stable=fc71a7e92dc2), phutil(head=stable, ref.stable=b10adc2e3f86)
  #0 AphrontBaseMySQLDatabaseConnection::throwConnectionException(integer, string, string, string) called at [<phutil>/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php:76]
  #1 AphrontMySQLiDatabaseConnection::connect() called at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:101]
  #2 AphrontBaseMySQLDatabaseConnection::establishConnection() called at [<phutil>/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:124]
  #3 AphrontBaseMySQLDatabaseConnection::requireConnection() called at [<phutil>/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php:15]
  #4 AphrontMySQLiDatabaseConnection::escapeBinaryString(string) called at [<phutil>/src/aphront/storage/connection/mysql/AphrontMySQLiDatabaseConnection.php:11]
  #5 AphrontMySQLiDatabaseConnection::escapeUTF8String(string) called at [<phutil>/src/xsprintf/qsprintf.php:178]
  #6 xsprintf_query(AphrontMySQLiDatabaseConnection, string, integer, string, integer) called at [<phutil>/src/xsprintf/xsprintf.php:70]
  #7 xsprintf(string, AphrontMySQLiDatabaseConnection, array) called at [<phutil>/src/xsprintf/qsprintf.php:64]
  #8 qsprintf(AphrontMySQLiDatabaseConnection, string, string, string, string)
  #9 call_user_func_array(string, array) called at [<phutil>/src/xsprintf/queryfx.php:5]
  #10 queryfx(AphrontMySQLiDatabaseConnection, string, string, string, string)
  #11 call_user_func_array(string, array) called at [<phutil>/src/xsprintf/queryfx.php:13]
  #12 queryfx_all(AphrontMySQLiDatabaseConnection, string, string, string, string)
  #13 call_user_func_array(string, array) called at [<phutil>/src/aphront/storage/connection/AphrontDatabaseConnection.php:52]
  #14 AphrontDatabaseConnection::queryData(string, string, string, string)
  #15 call_user_func_array(array, array) called at [<phabricator>/src/infrastructure/storage/lisk/LiskDAO.php:535]
  #16 LiskDAO::loadRawDataWhere(string, string)
  #17 call_user_func_array(array, array) called at [<phabricator>/src/infrastructure/storage/lisk/LiskDAO.php:476]
  #18 LiskDAO::loadAllWhere(string, string) called at [<phabricator>/src/infrastructure/env/PhabricatorConfigDatabaseSource.php:19]
  #19 PhabricatorConfigDatabaseSource::loadConfig(string) called at [<phabricator>/src/infrastructure/env/PhabricatorConfigDatabaseSource.php:7]
  #20 PhabricatorConfigDatabaseSource::__construct(string) called at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:238]
  #21 PhabricatorEnv::buildConfigurationSourceStack(boolean) called at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:95]
  #22 PhabricatorEnv::initializeCommonEnvironment(boolean) called at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:75]
  #23 PhabricatorEnv::initializeScriptEnvironment(boolean) called at [<phabricator>/scripts/init/lib.php:22]
  #24 init_phabricator_script(array) called at [<phabricator>/scripts/init/init-script.php:10]
  #25 require_once(string) called at [<phabricator>/scripts/__init_script__.php:3]
  #26 require_once(string) called at [<phabricator>/scripts/celerity/generate_sprites.php:4]
$ php5 --version
PHP 5.6.26-1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

I can't reproduce this. Here's what I did:

  • Switched to stable.
  • Ran bin/celerity map.

This worked correctly:

$ git checkout stable
Switched to branch 'stable'
Your branch is up-to-date with 'origin/stable'.
$ ./bin/celerity map
Rebuilding 3 resource source(s).
Rebuilding resource source "phabricator" (CelerityPhabricatorResources)...
Found 141 binary resources.
Found 386 text resources.
Found 11 packages.
...

Not having any issues on either of my dev machines either.

To allow me to debug this further: Is init with config.optional = false supposed to work without a MySQL server? Reading the code I would assume: No, but I want to make sure.

I'd be thrilled to answer questions about third-party application development or Phabricator's internals, but unfortunately we can't offer that for free -- it's very time consuming and usually only benefits one user. If you're interested in help with modifying Phabricator or developing third-party applications, see Consulting.

If you're unclear on what we offer help with, see Support Resources for details. We offer only a very narrow range of free support -- again, because most other things people want help with take up a ton of time and only help them.

See also T5447.

I hope it is clear from the commands and reproduction steps I posted above, that I did not modify the source of Phabricator in any way. I am working with the code straight out of Git, immediately running ./scripts/celerity/generate_sprites.php on it.

Looking at src/infrastructure/env/PhabricatorEnv.php:238 and following, it appears to me that failures to connect to the MySQL database are considered fatal, if config.optional=false. Thus scripts like ./scripts/celerity/generate_sprites.php cannot currently be run without setting up a MySQL server on the system. It would be great, if this would not be necessary. The change to allow for this seems to be trivial, assuming that these scripts do not actually need a database (they don't appear to need one on my system - the result that the hacked version produces seems fine).

P.S. Assuming that the current behaviour is intentional, this task should probably be considered to be a feature request.

It would be great, if this would not be necessary.

These scripts require a database. This is not a bug.

Feature requests require a root problem description (see Contributing Feature Requests and Describing Root Problems). Feel free to file a new feature request completely describing your root problem. If you do, please read all of the documentation carefully first: it lays out exactly what information we need to move forward on a feature request.

T11217 expects sprites to get generated from DB, for example.