Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tries to load dev bundle #65

Open
wyllyjon opened this issue Jun 28, 2018 · 16 comments
Open

Tries to load dev bundle #65

wyllyjon opened this issue Jun 28, 2018 · 16 comments

Comments

@wyllyjon
Copy link

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 !

@DavidFeller
Copy link

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?

@wyllyjon
Copy link
Author

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

@DavidFeller
Copy link

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

@YetiCGN
Copy link

YetiCGN commented Jul 2, 2018

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 added a commit to YetiCGN/easy-deploy-bundle that referenced this issue Jul 2, 2018
@numediaweb
Copy link

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/'];
      }

@YetiCGN
Copy link

YetiCGN commented Aug 20, 2018

@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.

@wyllyjon
Copy link
Author

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 !

@YetiCGN
Copy link

YetiCGN commented Aug 20, 2018

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.

@wyllyjon
Copy link
Author

Ok !

Thanks for the info !

@numediaweb
Copy link

numediaweb commented Oct 4, 2018

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

@YetiCGN
Copy link

YetiCGN commented Oct 10, 2018

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.

@javiereguiluz
Copy link
Contributor

@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 :)

@YetiCGN
Copy link

YetiCGN commented Oct 10, 2018

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.

@numediaweb
Copy link

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

@YetiCGN
Copy link

YetiCGN commented Jul 12, 2019

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

@DavidFeller
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants