luyadev / luya

LUYA is a scalable web framework and content management system with the goal to please developers, clients and users alike.
https://luya.io
MIT License
811 stars 205 forks source link

Deployment error after `composer update` #2052

Closed JohnnyMcWeed closed 4 years ago

JohnnyMcWeed commented 4 years ago

What steps will reproduce the problem?

I did composer update, added to git and then vendor\bin\dep luya prod -vvv

What is the expected result?

Normal deployment

What do you get instead? (A Screenshot can help us a lot!)

[prod] < Fatal error: Uncaught luya\Exception: config file '/prod/releases/18/vendor/luyadev/luya-core/bin/../../../../configs/env.php' found but no array returning. in /prod/releases/18/vendor/luyadev/luya-core/base/Boot.php:183
[prod] < Stack trace:
[prod] < #0 /prod/releases/18/vendor/luyadev/luya-core/base/Boot.php(219): luya\base\Boot->getConfigArray()
[prod] < #1 /prod/releases/18/vendor/luyadev/luya-core/bin/luya(36): luya\base\Boot->applicationConsole()
[prod] < #2 {main}  thrown in /prod/releases/18/vendor/luyadev/luya-core/base/Boot.php on line 183

In Client.php line 103:

  [Deployer\Exception\RuntimeException (255)]                                                                                                                                                                                          
  The command "/usr/bin/php ~/prod/releases/18/vendor/bin/luya migrate --interactive=0" failed.                                                                                                                          

  Exit Code: 255 (Unknown error)                                                                                                                                                                                                       

  Host Name: prod                                                                                                                                                                                                                      

  ================                                                                                                                                                                                                                     

  Fatal error: Uncaught luya\Exception: config file '/prod/releases/18/vendor/luyadev/luya-core/bin/../../../../configs/env.php' found but no array returning. in /prod/releases/18/vendor/luyadev/luya-core/base/Boot.php:183                                                                                                                                                                                                                
  Stack trace:                                                                                                                                                                                                                         
  #0 /prod/releases/18/vendor/luyadev/luya-core/base/Boot.php(219): luya\base\Boot->getConfigArray()                                                                                                                     
  #1 /prod/releases/18/vendor/luyadev/luya-core/bin/luya(36): luya\base\Boot->applicationConsole()                                                                                                                       
  #2 {main} thrown in /prod/releases/18/vendor/luyadev/luya-core/base/Boot.php on line 183                                                                                                                                       

Exception trace:
  at E:\Projekte\Project\vendor\deployer\deployer\src\Ssh\Client.php:103
 Deployer\Ssh\Client->run() at E:\Projekte\Project\vendor\deployer\deployer\src\functions.php:304
 Deployer\run() at E:\Projekte\Project\vendor\luyadev\luya-deployer\luya.php:56
 Deployer\Deployer::Deployer\{closure}() at n/a:n/a
 call_user_func() at E:\Projekte\Project\vendor\deployer\deployer\src\Task\Task.php:105
 Deployer\Task\Task->run() at E:\Projekte\Project\vendor\deployer\deployer\src\Executor\SeriesExecutor.php:60
 Deployer\Executor\SeriesExecutor->run() at E:\Projekte\Project\vendor\deployer\deployer\src\Console\TaskCommand.php:144
 Deployer\Console\TaskCommand->execute() at E:\Projekte\Project\vendor\symfony\console\Command\Command.php:258
 Symfony\Component\Console\Command\Command->run() at E:\Projekte\Project\vendor\symfony\console\Application.php:916
 Symfony\Component\Console\Application->doRunCommand() at E:\Projekte\Project\vendor\deployer\deployer\src\Console\Application.php:133
 Deployer\Console\Application->doRunCommand() at E:\Projekte\Project\vendor\symfony\console\Application.php:264
 Symfony\Component\Console\Application->doRun() at E:\Projekte\Project\vendor\symfony\console\Application.php:140
 Symfony\Component\Console\Application->run() at E:\Projekte\Project\vendor\deployer\deployer\src\Deployer.php:326
 Deployer\Deployer::run() at E:\Projekte\Project\vendor\deployer\deployer\bin\dep:137

luya [-p|--parallel] [-l|--limit LIMIT] [--no-hooks] [--log LOG] [--roles ROLES] [--hosts HOSTS] [-o|--option OPTION] [--] [<stage>]

Additional infos

Q A
LUYA Core before 1.6.1
LUYA Core after 1.7.0
LUYA Deployer before 2.0.2
LUYA Deployer after 2.0.3
nadar commented 4 years ago

what if you pin the deployer version again to 2.0.2 and test again? so we could find out whether is a problem with deployer or luya core.

cause i don't think we have changed something which should break that deployment in the core (https://github.com/luyadev/luya/compare/1.6.1...master)

Also the deployer changes are unlikely: https://github.com/luyadev/luya-deployer/compare/2.0.2...master

the luya bin is not in git folder?

The exception says config file '/prod/releases/18/vendor/luyadev/luya-core/bin/../../../../configs/env.php' found but no array returning. So what does the env.php file looks on the server? the env file is created by the deployer.

JohnnyMcWeed commented 4 years ago

Really strange... Thanks for the input about switching back. Just found out that when doing so it is no more working aswell... The env.php file looks correct. The process is working until the migrate command...

/prod/releases/18/luya exists.

env.php looks like this:

<?php
// generated at: Tue, 15 Sep 2020 18:54:22 +0000
// tag variable
$tag = '';
// check if new config.php file based config object exists.
$config = @include('config.php');
if ($config) {
    $config->application([
        'version' => ''
    ]);
    return $config->toArray(['prod']);
}
// use old include structure
return require 'env-prod.php';

But I just checked and they updated Plesk, maybe somehow related to this... But strange that the other things work until then...

nadar commented 4 years ago

are you working with config.php or with env-prod.php? Maybe you have a white space in the config or something? Please post the config (remove sensitiv data of course).

JohnnyMcWeed commented 4 years ago

I'm having the env-prod.php

<?php

use app\themes\zzztwenty\ZzzAssetBootstrap;

defined('YII_ENV') or define('YII_ENV', 'prod');
defined('YII_DEBUG') or define('YII_DEBUG', false);

$config = new \luya\Config('Glamourart', dirname(__dir__), [
    'id' => 'zzz2020',
    'siteTitle' => 'zzz',
    'defaultRoute' => 'cms',
    'basePath' => dirname(__DIR__),
    'bootstrap' => [
        ZzzAssetBootstrap::class,
    ],
    'ensureSecureConnection' => true,
    'modules' => [
        'admin' => [
            'class' => 'luya\admin\Module',
            'secureLogin' => true,
            'interfaceLanguage' => 'de',
            'strongPasswordPolicy' => true,
            'emailVerification' => true,
            'jsonCruft' => true,
        ],
        'cms' => [
            'class' => 'luya\cms\frontend\Module',
            'contentCompression' => true,
        ],
        'cmsadmin' => [
            'class' => 'luya\cms\admin\Module',
            'hiddenBlocks' => [],
            'blockVariations' => [],
        ],
        'galleryfrontend' => [
            'class' => 'luya\gallery\frontend\Module',
            'useAppViewPath' => false,
        ],
        'galleryadmin' => 'luya\gallery\admin\Module',
        'contactform' => [
            'class' => 'luya\contactform\Module',
//            'useAppViewPath' => true,
            'mailTitle' => 'Kontaktanfrage',
            'attributes' => [
                'forename', 'name', 'email', 'tel', 'subject', 'message',
            ],
            'rules' => [
                [['forename', 'name', 'email', 'tel', 'subject', 'message'], 'required'],
                ['email', 'email'],
            ],
            'attributeLabels' => [
                'forename' => 'contact.forename',
                'name' => 'contact.name',
                'email' => 'contact.email',
                'tel' => 'contact.tel',
                'subject' => 'contact.subject',
                'message' => 'contact.message'
            ],
            'recipients' => [
                'info@zzz.ch',
            ],
            'spamDetectionDelay' => 5,
        ],
        'basicauth' => [
            'class' => 'luya\basicauth\Module',
            'password' => '...',
        ],
        'sitemap' => [
            'class' => cebe\luya\sitemap\Module::class,
        ]
    ],
    'components' => [
        'mail' => [
            'host' => 'xyz.yyy.ch',
            'username' => 'mailer@zzz.ch',
            'password' => '...',
            'from' => 'info@zzz.ch',
            'fromName' => 'Something',
        ],
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=127.0.0.1;dbname=...',
            'username' => '...',
            'password' => '...',
            'charset' => 'utf8',
            'enableSchemaCache' => true,
            'schemaCacheDuration' => 43200,
        ],
        'composition' => [
            'hidden' => true,
            'default' => ['langShortCode' => 'de'],
            'allowedHosts' => [
                'prod.zzz.ch', 'zzz.ch',
            ]
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'i18n' => [
            'translations' => [
                'app*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                ],
            ],
        ],
    ],
    'params' => [
        'pageSuffix' => ' | ...',
        'mailInfo' => 'info@zzz.ch'
    ],
]);

$config->component('errorHandler', [
    'class' => 'luya\web\ErrorHandler',
    'api' => 'https://xxx.ch/errorapi',
    'transferException' => true,
]);

return $config;
nadar commented 4 years ago

and when you go to

/prod/releases/18/vendor/luyadev/luya-core/base/Boot.php(219): luya\base\Boot->getConfigArray()

in the prod server release 18 and var_dump what the getConfigArray() returns, what is the result?

JohnnyMcWeed commented 4 years ago

When adding var_dump($config); in luya-core\base\Boot on line 181 it's returning an object(luya\Config). The line after this checks for an array and throws the exception.

nadar commented 4 years ago

Then i would say this part does not work:

// check if new config.php file based config object exists.
$config = @include('config.php');
if ($config) {
    $config->application([
        'version' => ''
    ]);
    return $config->toArray(['prod']);
}

otherwise the config would be parsed to an array.

nadar commented 4 years ago

sorry, i overread that you have Config in your env-prod, it must be config.php. see the current build https://github.com/luyadev/luya-kickstarter/tree/master/configs

JohnnyMcWeed commented 4 years ago

So the docs must be adjusted to this 👍 https://luya.io/guide/install-structures

nadar commented 4 years ago

@JohnnyMcWeed would you please send a PR? Would be great. thansk!