[SOLVED] Core Exception during installation


#1

Hello, I’m trying to install phabricator on a Centos 7 shared hosting server, with Apache 2.4, PHP 7.1 and MariaDB 15.1.

I religiously followed the installation and configuration guides:
I successfully created the correct vhost configuration, set up a Let’s Encrypt SSL cert, the server is correctly using php-fpm to serve PHP files, I cloned phabricator, arcanist and libphutil, and checked out the stable branch in all three.
I’m stuck at the step “Setup” of the configuration guide, since as soon as I open it in my browser, the only thing displayed in the page is an exception:
[Core Exception/Exception] Trying to read configuration “security.alternate-file-domain” before configuration has been initialized.

I’ve tried to execute bin/storage upgrade, and it successfully created the schemata, but no change.
The php-fpm pool runs under an unprivileged user, it has full read-write access on its home directory and the github repos were cloned with that same user.

Is someone able to shed some light?


#2

Can you find a stack trace in the apache or php-fpm logs? This might show more information.


#3

Here is an extract from the php-fpm error log, from a single page load.
Nothing in the apache error log.

[05-Mar-2018 09:24:25 Europe/Rome] [2018-03-05 09:24:25] EXCEPTION: (Exception) Trying to read configuration "security.alternate-file-domain" before configuration has been initialized. at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:334]
[05-Mar-2018 09:24:25 Europe/Rome] arcanist(head=stable, ref.master=dcd7ef66d0e4, ref.stable=8fe1d7701e5d), phabricator(head=stable, ref.master=584495215301, ref.stable=ae7236c7a413), phutil(head=stable, ref.master=dedf260c7755, ref.stable=74e27a2b4a47)
[05-Mar-2018 09:24:25 Europe/Rome]   #0 <#2> PhabricatorEnv::getEnvConfig(string) called at [<phabricator>/src/aphront/response/AphrontResponse.php:108]
[05-Mar-2018 09:24:25 Europe/Rome]   #1 <#2> AphrontResponse::newContentSecurityPolicyHeader() called at [<phabricator>/src/aphront/response/AphrontResponse.php:91]
[05-Mar-2018 09:24:25 Europe/Rome]   #2 <#2> AphrontResponse::getHeaders() called at [<phabricator>/src/aphront/response/AphrontHTMLResponse.php:9]
[05-Mar-2018 09:24:25 Europe/Rome]   #3 <#2> AphrontHTMLResponse::getHeaders() called at [<phabricator>/src/aphront/sink/AphrontHTTPSink.php:107]
[05-Mar-2018 09:24:25 Europe/Rome]   #4 <#2> AphrontHTTPSink::writeResponse(PhabricatorConfigResponse) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:302]
[05-Mar-2018 09:24:25 Europe/Rome]   #5 <#2> AphrontApplicationConfiguration::writeResponse(AphrontPHPHTTPSink, PhabricatorConfigResponse) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:81]
[05-Mar-2018 09:24:25 Europe/Rome]   #6 <#2> AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phabricator>/webroot/index.php:17]
[05-Mar-2018 09:24:25 Europe/Rome]   #7 phlog(Exception) called at [<phabricator>/src/aphront/response/AphrontUnhandledExceptionResponse.php:20]
[05-Mar-2018 09:24:25 Europe/Rome]   #8 AphrontUnhandledExceptionResponse::setException(Exception) called at [<phabricator>/webroot/index.php:21]
[05-Mar-2018 09:24:25 Europe/Rome] [Core Exception/Exception] Trying to read configuration "security.alternate-file-domain" before configuration has been initialized.

#0 /home/repo/phabricator/src/aphront/response/AphrontResponse.php(108): PhabricatorEnv::getEnvConfig('security.altern...')
#1 /home/repo/phabricator/src/aphront/response/AphrontResponse.php(91): AphrontResponse->newContentSecurityPolicyHeader()
#2 /home/repo/phabricator/src/aphront/response/AphrontHTMLResponse.php(9): AphrontResponse->getHeaders()
#3 /home/repo/phabricator/src/aphront/sink/AphrontHTTPSink.php(107): AphrontHTMLResponse->getHeaders()
#4 /home/repo/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php(302): AphrontHTTPSink->writeResponse(Object(PhabricatorConfigResponse))
#5 /home/repo/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php(81): AphrontApplicationConfiguration::writeResponse(Object(AphrontPHPHTTPSink), Object(PhabricatorConfigResponse))
#6 /home/repo/phabricator/webroot/index.php(17): AphrontApplicationConfiguration::runHTTPRequest(Object(AphrontPHPHTTPSink))
#7 {main}
[05-Mar-2018 09:24:25 Europe/Rome] [2018-03-05 09:24:25] EXCEPTION: (Exception) Trying to read configuration "security.alternate-file-domain" before configuration has been initialized. at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:334]
[05-Mar-2018 09:24:25 Europe/Rome] arcanist(head=stable, ref.master=dcd7ef66d0e4, ref.stable=8fe1d7701e5d), phabricator(head=stable, ref.master=584495215301, ref.stable=ae7236c7a413), phutil(head=stable, ref.master=dedf260c7755, ref.stable=74e27a2b4a47)
[05-Mar-2018 09:24:25 Europe/Rome]   #0 <#2> PhabricatorEnv::getEnvConfig(string) called at [<phabricator>/src/aphront/response/AphrontResponse.php:108]
[05-Mar-2018 09:24:25 Europe/Rome]   #1 <#2> AphrontResponse::newContentSecurityPolicyHeader() called at [<phabricator>/src/aphront/response/AphrontResponse.php:91]
[05-Mar-2018 09:24:25 Europe/Rome]   #2 <#2> AphrontResponse::getHeaders() called at [<phabricator>/src/aphront/response/AphrontHTMLResponse.php:9]
[05-Mar-2018 09:24:25 Europe/Rome]   #3 <#2> AphrontHTMLResponse::getHeaders() called at [<phabricator>/src/aphront/sink/AphrontHTTPSink.php:107]
[05-Mar-2018 09:24:25 Europe/Rome]   #4 <#2> AphrontHTTPSink::writeResponse(PhabricatorConfigResponse) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:302]
[05-Mar-2018 09:24:25 Europe/Rome]   #5 <#2> AphrontApplicationConfiguration::writeResponse(AphrontPHPHTTPSink, PhabricatorConfigResponse) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:81]
[05-Mar-2018 09:24:25 Europe/Rome]   #6 <#2> AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phabricator>/webroot/index.php:17]
[05-Mar-2018 09:24:25 Europe/Rome]   #7 phlog(Exception) called at [<phabricator>/src/aphront/response/AphrontUnhandledExceptionResponse.php:20]
[05-Mar-2018 09:24:25 Europe/Rome]   #8 AphrontUnhandledExceptionResponse::setException(Exception) called at [<phabricator>/webroot/index.php:21]
[05-Mar-2018 09:24:25 Europe/Rome] [Core Exception/Exception] Trying to read configuration "security.alternate-file-domain" before configuration has been initialized.

#0 /home/repo/phabricator/src/aphront/response/AphrontResponse.php(108): PhabricatorEnv::getEnvConfig('security.altern...')
#1 /home/repo/phabricator/src/aphront/response/AphrontResponse.php(91): AphrontResponse->newContentSecurityPolicyHeader()
#2 /home/repo/phabricator/src/aphront/response/AphrontHTMLResponse.php(9): AphrontResponse->getHeaders()
#3 /home/repo/phabricator/src/aphront/sink/AphrontHTTPSink.php(107): AphrontHTMLResponse->getHeaders()
#4 /home/repo/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php(302): AphrontHTTPSink->writeResponse(Object(PhabricatorConfigResponse))
#5 /home/repo/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php(81): AphrontApplicationConfiguration::writeResponse(Object(AphrontPHPHTTPSink), Object(PhabricatorConfigResponse))
#6 /home/repo/phabricator/webroot/index.php(17): AphrontApplicationConfiguration::runHTTPRequest(Object(AphrontPHPHTTPSink))
#7 {main}

#4

Make this change:

diff --git a/src/aphront/response/AphrontResponse.php b/src/aphront/response/AphrontResponse.php
index 892417fcb..3387bcb1f 100644
--- a/src/aphront/response/AphrontResponse.php
+++ b/src/aphront/response/AphrontResponse.php
@@ -105,7 +105,7 @@ abstract class AphrontResponse extends Phobject {
 
     $csp = array();
 
-    $cdn = PhabricatorEnv::getEnvConfig('security.alternate-file-domain');
+    $cdn = false;
     if ($cdn) {
       $default = $this->newContentSecurityPolicySource($cdn);
     } else {

Then restart your webserver and reload the page. You should see some other error. Let us know what that error is so I can reproduce this?


#5

Made the change, now the error is:

[Core Exception/Exception] Trying to read configuration "phabricator.base-uri" before configuration has been initialized.

And the following is entered into the php-fpm error log:

[05-Mar-2018 15:07:30 Europe/Rome] [2018-03-05 15:07:30] EXCEPTION: (Exception) Trying to read configuration "phabricator.base-uri" before configuration has been initialized. at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:334]
[05-Mar-2018 15:07:30 Europe/Rome] arcanist(head=stable, ref.master=dcd7ef66d0e4, ref.stable=8fe1d7701e5d), phabricator(head=stable, ref.master=584495215301, ref.stable=ae7236c7a413), phutil(head=stable, ref.master=dedf260c7755, ref.stable=74e27a2b4a47)
[05-Mar-2018 15:07:30 Europe/Rome]   #0 <#2> PhabricatorEnv::getEnvConfig(string) called at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:497]
[05-Mar-2018 15:07:30 Europe/Rome]   #1 <#2> PhabricatorEnv::getAnyBaseURI() called at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:392]
[05-Mar-2018 15:07:30 Europe/Rome]   #2 <#2> PhabricatorEnv::getURI(string) called at [<phabricator>/src/aphront/response/AphrontResponse.php:117]
[05-Mar-2018 15:07:30 Europe/Rome]   #3 <#2> AphrontResponse::newContentSecurityPolicyHeader() called at [<phabricator>/src/aphront/response/AphrontResponse.php:91]
[05-Mar-2018 15:07:30 Europe/Rome]   #4 <#2> AphrontResponse::getHeaders() called at [<phabricator>/src/aphront/response/AphrontHTMLResponse.php:9]
[05-Mar-2018 15:07:30 Europe/Rome]   #5 <#2> AphrontHTMLResponse::getHeaders() called at [<phabricator>/src/aphront/sink/AphrontHTTPSink.php:107]
[05-Mar-2018 15:07:30 Europe/Rome]   #6 <#2> AphrontHTTPSink::writeResponse(PhabricatorConfigResponse) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:302]
[05-Mar-2018 15:07:30 Europe/Rome]   #7 <#2> AphrontApplicationConfiguration::writeResponse(AphrontPHPHTTPSink, PhabricatorConfigResponse) called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:81]
[05-Mar-2018 15:07:30 Europe/Rome]   #8 <#2> AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phabricator>/webroot/index.php:17]
[05-Mar-2018 15:07:30 Europe/Rome]   #9 phlog(Exception) called at [<phabricator>/src/aphront/response/AphrontUnhandledExceptionResponse.php:20]
[05-Mar-2018 15:07:30 Europe/Rome]   #10 AphrontUnhandledExceptionResponse::setException(Exception) called at [<phabricator>/webroot/index.php:21]
[05-Mar-2018 15:07:30 Europe/Rome] [Core Exception/Exception] Trying to read configuration "phabricator.base-uri" before configuration has been initialized.

#0 /home/repo/phabricator/src/infrastructure/env/PhabricatorEnv.php(497): PhabricatorEnv::getEnvConfig('phabricator.bas...')
#1 /home/repo/phabricator/src/infrastructure/env/PhabricatorEnv.php(392): PhabricatorEnv::getAnyBaseURI()
#2 /home/repo/phabricator/src/aphront/response/AphrontResponse.php(117): PhabricatorEnv::getURI('/')
#3 /home/repo/phabricator/src/aphront/response/AphrontResponse.php(91): AphrontResponse->newContentSecurityPolicyHeader()
#4 /home/repo/phabricator/src/aphront/response/AphrontHTMLResponse.php(9): AphrontResponse->getHeaders()
#5 /home/repo/phabricator/src/aphront/sink/AphrontHTTPSink.php(107): AphrontHTMLResponse->getHeaders()
#6 /home/repo/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php(302): AphrontHTTPSink->writeResponse(Object(PhabricatorConfigResponse))
#7 /home/repo/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php(81): AphrontApplicationConfiguration::writeResponse(Object(AphrontPHPHTTPSink), Object(PhabricatorConfigResponse))
#8 /home/repo/phabricator/webroot/index.php(17): AphrontApplicationConfiguration::runHTTPRequest(Object(AphrontPHPHTTPSink))
#9 {main}

#6

Try making this additional change?

diff --git a/src/aphront/response/AphrontResponse.php b/src/aphront/response/AphrontResponse.php
index 892417fcb..c9876f778 100644
--- a/src/aphront/response/AphrontResponse.php
+++ b/src/aphront/response/AphrontResponse.php
@@ -105,7 +105,7 @@ abstract class AphrontResponse extends Phobject {
 
     $csp = array();
 
-    $cdn = PhabricatorEnv::getEnvConfig('security.alternate-file-domain');
+    $cdn = false;
     if ($cdn) {
       $default = $this->newContentSecurityPolicySource($cdn);
     } else {
@@ -113,10 +113,7 @@ abstract class AphrontResponse extends Phobject {
       // a Phame blog on a custom domain or some other custom site, we'll still
       // serve resources from the main site. Include the main site explicitly.
 
-      $base_uri = PhabricatorEnv::getURI('/');
-      $base_uri = $this->newContentSecurityPolicySource($base_uri);
-
-      $default = "'self' {$base_uri}";
+      $default = "'self'";
     }
 
     $csp[] = "default-src {$default}";

#8

With this change, the setup page loads and tells me that phabricator is not happy to be restricted with an open_basedir.
That I can handle.

Do you think it’s safe to continue with the setup?

Note: no additional errors in php-fpm or httpd logs.


#9

Thanks, see https://secure.phabricator.com/D19172.

This is now in HEAD of master and stable, so to continue you should:

  • Revert the ad-hoc patches from this thread.
  • Upgrade phabricator/ to HEAD.
  • Continue normally.

Let me know if you run into issues.