Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel on App Engine Standard: The /srv/bootstrap/cache directory must be present and writable

I've been struggling with the Google App Engine Standard environment for a day now.

The error is as follows:

PHP Notice: Exception: The /srv/bootstrap/cache directory must be present and writable. in /srv/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php:168

I know that the /tmp folder is the only writable folder for the App Engine Standard environment. Therefore, my app.yaml have the following additional env_variables:

  APP_STORAGE: "/tmp"
  VIEW_COMPILED_PATH: "/tmp"

...my bootstrap/app.php contains this line:

$app->useStoragePath(env('APP_STORAGE', base_path() . '/tmp'));

...and my composer.json has these scripts to account for the change in configuration:

        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump"
        ],
        "post-install-cmd": [
            "composer dump-autoload",
            "php artisan config:clear",
            "php artisan cache:clear",
            "php artisan view:clear",
            "php artisan cache:clear",
            "php artisan regenerate:schoolCSS"
        ]

These are my drivers configured in app.yaml:

SESSION_DRIVER: database
BROADCAST_DRIVER: log
CACHE_DRIVER: database
QUEUE_DRIVER: sync

For some reason, I just can't seem to find a way to make the /tmp folder the folder where the cached views and config are put. Actually, I suspect that the ...:clear commands aren't even properly ran at all.

My application is just a blank white page now, regardless of the path. That's fair, as due to the unwritable cache, the views cannot be rendered and stored there.

The above configurations should match the tutorials for installing Laraval on Google App Engine Standard, such as this one: https://cloud.google.com/community/tutorials/run-laravel-on-appengine-standard.

In the cloud console, I've checked whether the /tmp folder exists, which is the case.

Anyways, all help is dearly appreciated. If you need more code snippets, just ask. I'll be happy to provide them.

like image 328
Thierry Maasdam Avatar asked Jul 07 '19 10:07

Thierry Maasdam


1 Answers

I found a simple solution for this problem. The directory where the Laravel application lives on Google App Engine Standard is read-only. So you have to write the cache files to /tmp.

You can change the paths by simple adding this environment variables to your app.yaml

APP_SERVICES_CACHE: /tmp/services.php
APP_PACKAGES_CACHE: /tmp/packages.php
APP_CONFIG_CACHE: /tmp/config.php
APP_ROUTES_CACHE: /tmp/routes.php
like image 91
Markus Avatar answered Oct 17 '22 05:10

Markus