Home Forums Support Self Hosted – System Settings update fails and leads to blank .env file

This topic contains 15 replies, has 2 voices, and was last updated by  Hillel Coren 3 years, 3 months ago.

Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #2032

    pixeljitsu
    Participant

    I’m on a self hosted install and I’ve tried this both with the files above the webroot and also with all the core files under the webroot (also named public) using the rewrite to remove public from the URL. Either way I have the same error.

    When updating the System Settings for the DB/STMP the process exits and all values in the .env are erased leaving the .env blank and InvoiceNinja non-functioning. Here is the specific error in the laravel.log:

    [2016-01-16 10:36:30] production.ERROR: exception 'ErrorException' with message 'Array to string conversion' in /srv/users/[snip]/public/app/Http/Controllers/AppController.php:169
    Stack trace:
    #0 /srv/users/[snip]/public/app/Http/Controllers/AppController.php(169): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Array to string...', '/srv/users/pixe...', 169, Array)
    #1 [internal function]: App\Http\Controllers\AppController->updateSetup()

    It cascades on from there for about 50 more lines.

    This is on a ServerPilot w/ Ubuntu 14.04 stack.

    Any ideas what might I need to do to fix this?

    Thanks

    #2033

    Hillel Coren
    Keymaster

    I’m not sure, I’m not able to reproduce the error. Are you using the latest version.

    Rather than use the page you can manually update the settings in the .env file.

    #2034

    pixeljitsu
    Participant

    Yup, I’m on the latest self-hosted dl. I have tried that, the issue is that the values shown in the System Settings page do not change and show the original values before updating.

    I’m not sure where to look for how these values are being set and why they do not match what is in the .env file. I can select which PHP version to use, right now i’m on 5.6 but switching versions does not seem to matter.

    Here is the full error in hopes that it will help. Please let me know if there’s anything I can do or try to make it easier to figure out this issue.

    [2016-01-16 10:35:38] production.ERROR: exception 'ErrorException' with message 'Array to string conversion' in /srv/users/..snip../public/app/Http/Controllers/AppController.php:169
    Stack trace:
    #0 /srv/users/..snip../public/app/Http/Controllers/AppController.php(169): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Array to string...', '/srv/users/snip...', 169, Array)
    #1 [internal function]: App\Http\Controllers\AppController->updateSetup()
    #2 /srv/users/..snip../public/vendor/compiled.php(8558): call_user_func_array(Array, Array)
    #3 /srv/users/..snip../public/vendor/compiled.php(8626): Illuminate\Routing\Controller->callAction('updateSetup', Array)
    #4 /srv/users/..snip../public/vendor/compiled.php(8605): Illuminate\Routing\ControllerDispatcher->call(Object(App\Http\Controllers\AppController), Object(Illuminate\Routing\Route), 'updateSetup')
    #5 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
    #6 /srv/users/..snip../public/vendor/compiled.php(9244): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
    #7 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
    #8 /srv/users/..snip../public/vendor/compiled.php(9227): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
    #9 /srv/users/..snip../public/vendor/compiled.php(8606): Illuminate\Pipeline\Pipeline->then(Object(Closure))
    #10 /srv/users/..snip../public/vendor/compiled.php(8592): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(App\Http\Controllers\AppController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'updateSetup')
    #11 /srv/users/..snip../public/vendor/compiled.php(7583): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'App\\Http\\Contro...', 'updateSetup')
    #12 /srv/users/..snip../public/vendor/compiled.php(7554): Illuminate\Routing\Route->runWithCustomDispatcher(Object(Illuminate\Http\Request))
    #13 /srv/users/..snip../public/vendor/compiled.php(7219): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
    #14 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
    #15 /srv/users/..snip../public/vendor/compiled.php(9244): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
    #16 /srv/users/..snip../public/app/Http/Middleware/Authenticate.php(47): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
    #17 /srv/users/..snip../public/vendor/compiled.php(9236): App\Http\Middleware\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure))
    #18 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
    #19 /srv/users/..snip../public/vendor/compiled.php(9227): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
    #20 /srv/users/..snip../public/vendor/compiled.php(7220): Illuminate\Pipeline\Pipeline->then(Object(Closure))
    #21 /srv/users/..snip../public/vendor/compiled.php(7209): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
    #22 /srv/users/..snip../public/vendor/compiled.php(7194): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
    #23 /srv/users/..snip../public/vendor/compiled.php(2040): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
    #24 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
    #25 /srv/users/..snip../public/vendor/compiled.php(9244): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
    #26 /srv/users/..snip../public/vendor/barryvdh/laravel-debugbar/src/Middleware/Debugbar.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
    #27 /srv/users/..snip../public/vendor/compiled.php(9236): Barryvdh\Debugbar\Middleware\Debugbar->handle(Object(Illuminate\Http\Request), Object(Closure))
    #28 /srv/users/..snip../public/app/Http/Middleware/StartupCheck.php(183): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
    #29 /srv/users/..snip../public/vendor/compiled.php(9236): app\Http\Middleware\StartupCheck->handle(Object(Illuminate\Http\Request), Object(Closure))
    #30 /srv/users/..snip../public/app/Http/Middleware/DuplicateSubmissionCheck.php(28): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
    #31 /srv/users/..snip../public/vendor/compiled.php(9236): app\Http\Middleware\DuplicateSubmissionCheck->handle(Object(Illuminate\Http\Request), Object(Closure))
    #32 /srv/users/..snip../public/vendor/compiled.php(2548): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
    #33 /srv/users/..snip../public/app/Http/Middleware/VerifyCsrfToken.php(39): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
    #34 /srv/users/..snip../public/vendor/compiled.php(9236): App\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
    #35 /srv/users/..snip../public/vendor/compiled.php(12416): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
    #36 /srv/users/..snip../public/vendor/compiled.php(9236): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
    #37 /srv/users/..snip../public/vendor/compiled.php(11106): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
    #38 /srv/users/..snip../public/vendor/compiled.php(9236): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
    #39 /srv/users/..snip../public/vendor/compiled.php(12118): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
    #40 /srv/users/..snip../public/vendor/compiled.php(9236): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
    #41 /srv/users/..snip../public/vendor/compiled.php(12066): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
    #42 /srv/users/..snip../public/vendor/compiled.php(9236): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
    #43 /srv/users/..snip../public/vendor/compiled.php(2589): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
    #44 /srv/users/..snip../public/vendor/compiled.php(9236): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
    #45 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
    #46 /srv/users/..snip../public/vendor/compiled.php(9227): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
    #47 /srv/users/..snip../public/vendor/compiled.php(1996): Illuminate\Pipeline\Pipeline->then(Object(Closure))
    #48 /srv/users/..snip../public/vendor/compiled.php(1983): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
    #49 /srv/users/..snip../public/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
    #50 {main}  
    [2016-01-16 10:36:30] production.ERROR: exception 'ErrorException' with message 'Array to string conversion' in /srv/users/..snip../public/app/Http/Controllers/AppController.php:169
    #2035

    Hillel Coren
    Keymaster

    Is it possible you have multiple installations of the app, changes to the .env file should be reflected on the settings page. You can try adding dd(‘hello’) to the top of app/Http/routes.php to check.

    #2036

    pixeljitsu
    Participant

    I’m sure there is only one instance, a rsync or ftp (tried both) of the code to an empty app folder on the server errors out. Adding dd(β€˜hello’) just shows a page with “Hello” and stops the render.

    It is really strange, if I change the db password in the .env file the app will fail, but if I change any of the other values like the MAIL_PORT, they do not update on the settings page.

    Even with MAIL_PORT=485 in the .env file the system settings page displays 587.

    I’ve verified the DB collation and the .env file is 644.

    Not sure what would cause the array to string conversion error. It seems like it opens the file to write the config changes, fails with the file open and then exits leaving an empty file.

    #2037

    Hillel Coren
    Keymaster

    Maybe try adding dd($_ENV) in AppController.php before the foreach to try to track down the ‘array to string’ error.

    #2038

    pixeljitsu
    Participant

    This is on a subdomain BTW if that helps. Have set the rewrite base.

    #2039

    pixeljitsu
    Participant

    Like this?

            $config = '';
            dd($_ENV);
            foreach ($_ENV as $key => $val) {
                $config .= "{$key}={$val}\n";
            }

    Thanks for the help BTW πŸ™‚

    #2040

    Hillel Coren
    Keymaster

    Yup.

    Of course (although I’m heading out soon, will be back tomorrow).

    #2041

    pixeljitsu
    Participant

    OK. Does this look odd?

    "REQUEST_URI" => "/update_setup"
      "SCRIPT_NAME" => "/public/index.php"
      "PHP_SELF" => "/public/index.php"
      "REQUEST_TIME_FLOAT" => 1452977362.7103
      "REQUEST_TIME" => 1452977362
      "argv" => [] 
      "argc" => 0

    Not sure what argv" => [] would be.

    #2042

    Hillel Coren
    Keymaster

    When I compare it to my dev environment I don’t have any of those settings in $_ENV.

    #2043

    pixeljitsu
    Participant

    I’ll keep at it and hit you up later. Thanks again for your effort to help πŸ™‚

    #2044

    pixeljitsu
    Participant

    OK, did a complete DB and Server wipe and working from a totally fresh install.

    The System settings page was showing wrong values because of an auto formfill I did not realize was turned on, my bad I know 😐 The values now show exactly what is in the .ENV as expected.

    The $_ENV dump has now changed and no longer shows the strange stuff I posted before. Here is the full output, it seems to stop on the cookie value:

    array:76 [
      "TMP" => "/srv/users/[snip]"
      "TEMP" => "/srv/users/[snip]"
      "TMPDIR" => "/srv/users/[snip]"
      "PATH" => "/sbin:/usr/sbin:/bin:/usr/bin"
      "USER" => "[snip]"
      "HOME" => "/srv/users/[snip]"
      "FCGI_ROLE" => "RESPONDER"
      "REDIRECT_SCRIPT_URL" => "/update_setup"
      "REDIRECT_SCRIPT_URI" => "http://[snip]/update_setup"
      "REDIRECT_STATUS" => "200"
      "SCRIPT_URL" => "/update_setup"
      "SCRIPT_URI" => "http://[snip]/update_setup"
      "HTTP_HOST" => "[snip]"  (<-- No http:// on this)
      "HTTP_X_FORWARDED_FOR" => "[snip]"
      "HTTP_CONNECTION" => "close"
      "CONTENT_LENGTH" => "520"
      "HTTP_CACHE_CONTROL" => "max-age=0"
      "HTTP_ACCEPT" => "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
      "HTTP_ORIGIN" => "http://[snip]"
      "HTTP_UPGRADE_INSECURE_REQUESTS" => "1"
      "HTTP_USER_AGENT" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36"
      "CONTENT_TYPE" => "application/x-www-form-urlencoded"
      "HTTP_DNT" => "1"
      "HTTP_REFERER" => "http://[snip]/settings/system_settings"
      "HTTP_ACCEPT_ENCODING" => "gzip, deflate"
      "HTTP_ACCEPT_LANGUAGE" => "en-US,en;q=0.8"
      "HTTP_COOKIE" => "remember_[snip]; XSRF-TOKEN=[snip]  (<-- No closing quote here)

    Saving the System Settings still leads to an empty .ENV file. Also, from further testing I’ve noticed that the CSV export fails with a 500 error. I’ve make sure execution time, and max_input_vars are pretty liberal.

    If you need, email me, and I can give you the full phpInfo if that would help.

    Thanks for your time. I am really impressed with InvoiceNinja and am excited to start using it. If only I can get these couple of issues worked out. πŸ™‚

    #2045

    pixeljitsu
    Participant

    Update: CSV exports fail on PHP 5.6 but work on PHP 7

    #2047

    pixeljitsu
    Participant

    Just upgraded to 2.4.9.6 Still same issues.

    #2049

    Hillel Coren
    Keymaster

    As mentioned earlier you don’t need to use the system settings page, you can configure the app by manually by updating the .env file. If the settings appear wrong because of autofill settings they can be ignored. We’ll look into disabling autofill on the page.

    If you can send us the error you see in storage/logs/laravel.log when importing on PHP 5.6 it’d be helpful.

Viewing 16 posts - 1 through 16 (of 16 total)

You must be logged in to reply to this topic.

Posted in: