jalogut / magento2-deployer-plus

Tool based on deployer.org to perform zero downtime deployments of Magento 2 projects
GNU General Public License v3.0
200 stars 60 forks source link

Fixes #29: Generated directory is now cleared before DI compilation. #34

Closed erfanimani closed 5 years ago

erfanimani commented 5 years ago

Hmm my fix actually doesn't work for some reason.. I'll check it out later.

[localhost] < Generating optimized autoload files
• done on [localhost]
✔ Ok [2s 435ms]
➤ Executing task config:remove-dev-modules
• done on [localhost]
✔ Ok [1ms]
➤ Executing task files:remove-generated
[localhost] > cd . && (cd . && rm -rf generated/*)
• done on [localhost]
✔ Ok [112ms]
➤ Executing task files:compile
[localhost] > cd . && (/usr/local/bin/php ./bin/magento setup:di:compile)
[localhost] < Warning: include(/buddy/my-project/vendor/composer/../../generated/code/Magento/Framework/App/ResourceConnection/Proxy.php): failed to open stream: No such file or directory in /buddy/my-project/vendor/composer/ClassLoader.php on line 444
In Process.php line 239:

  [Symfony\Component\Process\Exception\ProcessFailedException]                 
  The command "cd . && (/usr/local/bin/php ./bin/magento setup:di:compile)" f  
  ailed.                                                                       

  Exit Code: 1(General error)                                                  

  Working directory: /buddy/my-project                                        

  Output:                                                                      
  ================                                                             
  Warning: include(/buddy/my-project/vendor/composer/../../generated/code/Ma  
  gento/Framework/App/ResourceConnection/Proxy.php): failed to open stream: N  
  o such file or directory in /buddy/my-project/vendor/composer/ClassLoader.  
  php on line 444                                                              

  Error Output:                                                                
  ================                                                             

Exception trace:
 Symfony\Component\Process\Process->mustRun() at phar:///buddy/my-project/vendor/deployer/dist/dep/src/Utility/ProcessRunner.php:51
 Deployer\Utility\ProcessRunner->run() at phar:///buddy/my-project/vendor/deployer/dist/dep/src/functions.php:301
 Deployer\run() at phar:///buddy/my-project/vendor/deployer/dist/dep/src/functions.php:154
 Deployer\{closure}() at n/a:n/a
 call_user_func() at phar:///buddy/my-project/vendor/deployer/dist/dep/src/Task/Task.php:105
 Deployer\Task\Task->run() at phar:///buddy/my-project/vendor/deployer/dist/dep/src/Executor/SeriesExecutor.php:60
 Deployer\Executor\SeriesExecutor->run() at phar:///buddy/my-project/vendor/deployer/dist/dep/src/functions.php:416
 Deployer\invoke() at /buddy/my-project/vendor/jalogut/magento2-deployer-plus/recipe/magento_2_2.php:31
 Deployer\Deployer::Deployer\{closure}() at n/a:n/a
 call_user_func() at phar:///buddy/my-project/vendor/deployer/dist/dep/src/Task/Task.php:105
 Deployer\Task\Task->run() at phar:///buddy/my-project/vendor/deployer/dist/dep/src/Executor/SeriesExecutor.php:55
 Deployer\Executor\SeriesExecutor->run() at phar:///buddy/my-project/vendor/deployer/dist/dep/src/Console/TaskCommand.php:142
 Deployer\Console\TaskCommand->execute() at phar:///buddy/my-project/vendor/deployer/dist/dep/vendor/symfony/console/Command/Command.php:252
 Symfony\Component\Console\Command\Command->run() at phar:///buddy/my-project/vendor/deployer/dist/dep/vendor/symfony/console/Application.php:946
 Symfony\Component\Console\Application->doRunCommand() at phar:///buddy/my-project/vendor/deployer/dist/dep/src/Console/Application.php:133
 Deployer\Console\Application->doRunCommand() at phar:///buddy/my-project/vendor/deployer/dist/dep/vendor/symfony/console/Application.php:248
 Symfony\Component\Console\Application->doRun() at phar:///buddy/my-project/vendor/deployer/dist/dep/vendor/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at phar:///buddy/my-project/vendor/deployer/dist/dep/src/Deployer.php:331
 Deployer\Deployer::run() at phar:///buddy/my-project/vendor/deployer/dist/dep/bin/dep:125
 require() at /buddy/my-project/vendor/deployer/dist/dep:4
build [-p|--parallel] [-l|--limit LIMIT] [--no-hooks] [--log LOG] [--roles ROLES] [--hosts HOSTS] [-o|--option OPTION] [--] [<stage>]
Action failed: see logs above for details
erfanimani commented 5 years ago

Fixed now — obviously I had to deploy:vendor after deleting generated.

The issue was that the Composer autoloader got out of sync with the generated codebase.

I.e. if you do

  1. di:compile
  2. composer install --optimize-autoloader

Now your autoloader contains classes from the generated directory (because they're included since 2.2.6).

so then if you run

  1. rm -rf generated/*
  2. di:compile

It will complain about not being able to find classes (since we just deleted the generated directory).

CC @stu177

jalogut commented 5 years ago

Hi @erfanimani

Thank you very much for checking it. I merged it and created a new release 2.5.0.