easy-deploy-bundle icon indicating copy to clipboard operation
easy-deploy-bundle copied to clipboard

Tries to load dev bundle

Open wyllyjon opened this issue 6 years ago • 16 comments

Hello,

I am trying to deploy my 3.4 app, and during the Preparing app stage, I have this error :

The command "ssh -A petitecolo '(export APP_ENV=prod; cd /home/www/beta/releases/20180628172057 && /home/www/bin/composer install --no-dev --prefer-dist --no-interaction --quiet)'" failed.                     
                                                                                                                                                                                                                   
  Exit Code: 1(General error)                                                                                                                                                                                      
                                                                                                                                                                                                                   
  Working directory: /media/jon/Projets/Projets/LeCoinEcolo.fr/symfony                                                                                                                                             
                                                                                                                                                                                                                   
  Output:                                                                                                                                                                                                          
  ================                                                                                                                                                                                                 
                                                                                                                                                                                                                   
                                                                                                                                                                                                                   
  Error Output:                                                                                                                                                                                                    
  ================                                                                                                                                                                                                 
  Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception                                                                       
                                                                                                                                                                                                                   
                                                                                                                                                                                       
    [RuntimeException]                                                                                                                                                                                             
                                                                                                                                                                                                                   
    An error occurred when executing the "'cache:clear --no-warmup'" command:                                                                                                                                      
                                                                                                                                                           
    Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "DoctrineFixturesBundle" from namespace "Doctrine\Bundle\FixturesBundle".                              
                                                                                                                                                                                                                   
    Did you forget a "use" statement for another namespace? in /home/www/beta/releases/20180628172057/app/AppKernel.php:45                                                                                         
                                                                                                                                                                                                                   
    Stack trace:                                                                                                                                                                                                   
                                                                                                                                                                                                                   
    #0 /home/www/beta/releases/20180628172057/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(492): AppKernel->registerBundles()                                                                
                                                                                                                                                                                                                   
    #1 /home/www/beta/releases/20180628172057/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(132): Symfony\Component\HttpKernel\Kernel->initializeBundles()                                    
                                                                                                                                                                                                                   
    #2 /home/www/beta/releases/20180628172057/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(64): Symfony\Component\HttpKernel\Kernel->boot()                                   
                                                                                                                                                                                                                   
    #3 /home/www/beta/releases/20180628172057/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(148): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Conso  
  le\Input\ArgvInput), Object(Symfo in /home/www/beta/releases/20180628172057/app/AppKernel.php on line 45                                                                                                         
                                                                                                                                                                                                                   
                                                                                                                                                                                                                   
                                                                                                                                                                                                                   
  install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoload  
  er] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...                  

It uses APP_ENV, but I think it is a SF4 env variable (SYMFONY_ENV for SF 3.4), maybe that is why it tries to load a dev bundle (DoctrineFixturesBundle).

I tried to add in beforeStartingDeploy() a $this->runRemote('export SYMFONY_ENV=prod'); but I do have the error anyway.

Any clue ?

Thanks all !

wyllyjon avatar Jun 28 '18 15:06 wyllyjon

I have the same problem. As a temporary workaround I ended up overriding $this->_symfonyEnvironmentEnvVarName (line 385) in DefaultConfiguration.php, but as @wyllyjon mentioned SF3.4 always seems to be handled like a flex app.

Is there any configuration option we are not aware of?

DavidFeller avatar Jun 28 '18 18:06 DavidFeller

@DavidFeller, had you overridden it directly in the vendor folder or is there a way to override it properly ?

wyllyjon avatar Jun 28 '18 18:06 wyllyjon

I've overridden it only for testing purposes, but haven't had time to work on a proper solution, yet

DavidFeller avatar Jun 28 '18 19:06 DavidFeller

Yes, this is a problem if you use the Symfony 3 directory structure with 3.4 as the bundle assumes Symfony 4 directory structure and env variable name, which can't be changed from outside. See #66, too.

YetiCGN avatar Jul 02 '18 11:07 YetiCGN

The issue is caused by those lines:

// vendor/easycorp/easy-deploy-bundle/src/Configuration/DefaultConfiguration.php:377

        } elseif (3 === $symfonyMajorVersion && 4 < $symfonyMinorVersion) {
            $this->_symfonyEnvironmentEnvVarName = 'SYMFONY_ENV';
            $this->setDirs('bin', 'app/config', 'var/cache', 'var/logs', 'src', 'app/Resources/views', 'web');
            $this->controllersToRemove(['web/app_*.php']);
            $this->sharedFiles = ['app/config/parameters.yml'];
            $this->sharedDirs = ['var/logs'];
            $this->writableDirs = ['var/cache/', 'var/logs/'];
        } elseif (4 === $symfonyMajorVersion || (3 === $symfonyMajorVersion && 4 >= $symfonyMinorVersion)) {
            $this->_symfonyEnvironmentEnvVarName = 'APP_ENV';
            $this->setDirs('bin', 'config', 'var/cache', 'var/log', 'src', 'templates', 'public');
            $this->controllersToRemove([]);
            $this->sharedDirs = ['var/log'];
            $this->writableDirs = ['var/cache/', 'var/log/'];
        }

It assumes that Symfony 3.4 is using Symfony's 4 directory structure which is wrong!

This is what fixed it for me:

    } elseif (3 === $symfonyMajorVersion) {
          $this->_symfonyEnvironmentEnvVarName = 'SYMFONY_ENV';
          $this->setDirs('bin', 'app/config', 'var/cache', 'var/logs', 'src', 'app/Resources/views', 'web');
          $this->controllersToRemove(['web/app_*.php']);
          $this->sharedFiles = ['app/config/parameters.yml'];
          $this->sharedDirs = ['var/logs'];
          $this->writableDirs = ['var/cache/', 'var/logs/'];
      } elseif (4 === $symfonyMajorVersion) {
          $this->_symfonyEnvironmentEnvVarName = 'APP_ENV';
          $this->setDirs('bin', 'config', 'var/cache', 'var/log', 'src', 'templates', 'public');
          $this->controllersToRemove([]);
          $this->sharedDirs = ['var/log'];
          $this->writableDirs = ['var/cache/', 'var/log/'];
      }

numediaweb avatar Aug 19 '18 12:08 numediaweb

@numediaweb Take a look at my PR. It enables you to set the directory layout from the outside without patching the DefaultConfiguration class. Because you could the 4 directory layout already with 3.4 and your change wouldn't work then.

YetiCGN avatar Aug 20 '18 07:08 YetiCGN

Hello YetiCGN !

How do you set the directory layout from outside ? I have looked at your commit, but I don't understand how it can be made ?

tks !

wyllyjon avatar Aug 20 '18 08:08 wyllyjon

Hi @wyllyjon,

the code to do this with the forked repo is

    return $this->getConfigBuilder()
        ->setDefaultConfiguration(\EasyCorp\Bundle\EasyDeployBundle\Configuration\DefaultConfiguration::SYMFONY_3)

(or any other of the constants) and then continuing to use the builder in your deploy.php.

YetiCGN avatar Aug 20 '18 08:08 YetiCGN

Ok !

Thanks for the info !

wyllyjon avatar Aug 20 '18 08:08 wyllyjon

@javiereguiluz Can the PR from @YetiCGN be merged please?

numediaweb avatar Oct 04 '18 12:10 numediaweb

Seems this project is unmaintained / abandoned. No commit or merge for almost 6 months. If you add this block to your composer.json and switch the required version to dev-master it will pull my forked version:

[...]
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/YetiCGN/easy-deploy-bundle"
    }
],
"require-dev": {
    "easycorp/easy-deploy-bundle": "dev-master",
[...]

Use at your own risk. Should this project be picked up again I can't guarantee to pull all changes to my fork.

YetiCGN avatar Oct 10 '18 13:10 YetiCGN

@YetiCGN it may look abandoned ... but it's not. I use this bundle every day to deploy multiple personal projects. It's working fine to me :)

javiereguiluz avatar Oct 10 '18 13:10 javiereguiluz

Hey, Javier! Thanks for stopping by. I am using it (almost) every day as well to deploy a project, but I have to use my fork since it's a Symfony 3.4 project. By abandoned I meant that development has stopped almost half a year ago with no comments on 9 open pull requests from contributors. It's great to see you're still commenting here, but frankly I've decided to switch to Deployer for new projects although easy-deploy-bundle looked promising.

YetiCGN avatar Oct 10 '18 13:10 YetiCGN

Still having this issue when using Symfony v3.4.29 @javiereguiluz can you please merge the PR?

numediaweb avatar Jul 12 '19 14:07 numediaweb

@numediaweb Switch to https://github.com/deployphp/deployer/, it's much more flexible and readily maintained. I did and never regretted it.

YetiCGN avatar Jul 12 '19 14:07 YetiCGN

@numediaweb: I agree with @YetiCGN. I did the same.

DavidFeller avatar Jul 12 '19 14:07 DavidFeller