2
votes

I get a blank screen, but here is the result from the error log. It appears to be pre-pending everything with /tmp/build_xxxx...

both dev & prod work fine locally.

Code is here... https://github.com/TransformCore/dial-tone-frontend

2014-11-25T14:43:27.388147+00:00 heroku[router]: at=info method=GET path="/css/bootstrap.css" host=dial-tone-frontend.herokuapp.com request_id=1bdcc1f4-4d8b-42b0-a85d-8b265d2665bd fwd="80.5.64.178" dyno=web.1 connect=1ms service=8ms status=500 bytes=208 2014-11-25T14:43:27.388931+00:00 app[web.1]: [2014-11-25 14:43:27] request.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The file "/tmp/build_23552b1c8333d8e8b9b475444451531c/app/config/routing.yml" does not exist." at /app/app/cache/prod/classes.php line 1575 {"exception":"[object] (InvalidArgumentException: The file \"/tmp/build_23552b1c8333d8e8b9b475444451531c/app/config/routing.yml\" does not exist. at /app/app/cache/prod/classes.php:1575)"} [] 2014-11-25T14:43:27.390315+00:00 app[web.1]: [25-Nov-2014 14:43:27 UTC] PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'The file "/tmp/build_23552b1c8333d8e8b9b475444451531c/app/config/routing.yml" does not exist.' in /app/app/cache/prod/classes.php:1575 2014-11-25T14:43:27.390355+00:00 app[web.1]: Stack trace: 2014-11-25T14:43:27.390525+00:00 app[web.1]: #0 /app/app/cache/prod/classes.php(2301): Symfony\Component\Config\FileLocator->locate('/tmp/build_2355...', NULL, true) 2014-11-25T14:43:27.390779+00:00 app[web.1]: #1 /app/vendor/symfony/symfony/src/Symfony/Component/Routing/Loader/YamlFileLoader.php(49): Symfony\Component\HttpKernel\Config\FileLocator->locate('/tmp/build_2355...') 2014-11-25T14:43:27.391220+00:00 app[web.1]: #3 /app/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php(58): Symfony\Component\Config\Loader\DelegatingLoader->load('/tmp/build_2355...', NULL) 2014-11-25T14:43:27.391369+00:00 app[web.1]: #4 /app/app/cache/prod/classes.php(1502): Symfony\Bundle\FrameworkBundle\Routing\DelegatingLoader->load('/tmp/build_2355...', NULL) 2014-11-25T14:43:27.391484+00:00 app[web.1]: #5 /app/app/cache/prod/classes.php( in /app/app/cache/prod/classes.php on line 1575 2014-11-25T14:43:27.391759+00:00 app[web.1]: 10.36.138.222 - - [25/Nov/2014:14:43:27 +0000] "GET /css/bootstrap.css HTTP/1.1" 500 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36" 2014-11-25T14:43:27.389956+00:00 app[web.1]: [2014-11-25 14:43:27] request.CRITICAL: Exception thrown when handling an exception (Twig_Error_Loader: The "/tmp/build_23552b1c8333d8e8b9b475444451531c/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/views" directory does not exist.) {"exception":"[object] (InvalidArgumentException: The file \"/tmp/build_23552b1c8333d8e8b9b475444451531c/app/config/routing.yml\" does not exist. at /app/app/cache/prod/classes.php:1575)"} [] 2014-11-25T14:43:27.390994+00:00 app[web.1]: #2 /app/vendor/symfony/symfony/src/Symfony/Component/Config/Loader/DelegatingLoader.php(45): Symfony\Component\Routing\Loader\YamlFileLoader->load('/tmp/build_2355...', NULL)

1
I would clear the cache and do a composer update before deploying. From your logs, it looks like some of the vendor bundles are not installing properly on deployment. what is the output in the terminal when you deploy to heroku?Sehael
I have done what you suggested, clearing the cache & doing a composer update before deploy. It deploys successfully, there are no errors. I think it is something to do with this build_23552b1c8333d8e8b9b475444451531c path causing an issue?Eddie Jaoude
no, heroku builds to the tmp directory by default with a name like that, and then packages your application to run. The output after running heroku push master or whatever will tell you exactly which bundles are installed. It seems like some are missing. You can go through the output and your composer.json and make sure they are all there.Sehael
It doesn't seem like anything is missing from the listsEddie Jaoude
I started a new project & followed both Symfony2 & Heroku with Symfony2 documentation & they both give the same error, that the cache generated is in the wrong paths. Ref: devcenter.heroku.com/articles/getting-started-with-symfony2Eddie Jaoude

1 Answers

1
votes

I think the problem is that in production environment uses a cached version of '%kernel.root_dir%'.

Heroku build the slug in a directory like '/tmp/build...' but runs it in the directory /app.

The only workaround that I found is to change the logic used to calculate the root directory.

I changed my 'app/AppKernel.php' adding this method:

public function getRootDir()
{
  if (isset($_ENV['SYMFONY_ENV']) && $_ENV['SYMFONY_ENV'] == 'prod') {
    // Workaround to avoid problem with the slug of heroku
    return '/app/app';
  }
  return parent::getRootDir();
}