roots / sage

WordPress starter theme with Laravel Blade components and templates, Tailwind CSS, and a modern development workflow
https://roots.io/sage/
MIT License
12.71k stars 3.06k forks source link

Bug: [Sage 10] `acorn/framework directory must be present` #2946

Closed strarsis closed 2 years ago

strarsis commented 2 years ago

Description

What's wrong?

After installing the latest Sage 10 commit using composer create-project roots/sage sage10 dev-main an error occurs in backend and frontend after activating that theme:

Fatal error: Uncaught Exception: The /srv/www/web/app/cache/acorn/framework directory must be present. in /srv/www/web/app/themes/sage10/vendor/roots/acorn/src/Roots/Acorn/Application.php on line 124

What have you tried?

I ensured that all theme dev dependencies were installed and yarn build successfully ran in order to initialize the theme.

What insights have you gained?

The directory web/app/cache/acorn/framework and web/app/cache/acorn/framework/cache indeed don't exist yet for that site (web/app/cache/acorn/ does exist, there is no framework/cache/ folder inside though). Just creating the framework/ directory will result in a slightly different fatal error, where now the framework/cache/ folder is missing.

Possible solutions

Manually ensuring that the directory framework/, framework/cache/ and the directory structure web/app/cache/acorn/framework exists.

Temporary workarounds

Manually creating the framework/ and framework/cache/ directory.

Steps To Reproduce

  1. Create a Sage 10 based theme from latest master using the command composer create-project roots/sage sage10 dev-main.
  2. Install theme dev dependencies: nvm use lts/* && npm install -g npm && npm install -g yarn && yarn install && yarn build.
  3. Activate that theme in WordPress. Note the fatal error that follows, both in backend and frontend:
    Fatal error: Uncaught Exception: The /srv/www/web/app/cache/acorn/framework directory must be present. in /srv/www/web/app/themes/sage10/vendor/roots/acorn/src/Roots/Acorn/Application.php on line 124
  4. Manually create that directory /srv/www/web/app/cache/acorn/framework.
  5. Reload a page. Note that another sub-directory is also expected to be present and writable:
    The /srv/www/web/app/cache/acorn/framework/cache directory must be present and writable.
  6. Manually create also that directory /srv/www/web/app/cache/acorn/framework/cache.
  7. Reload a page. Note that the fatal errors are now gone and the theme loads in backend and frontend without issues.

Expected Behavior

No fatal errors after activating a fresh Sage 10 theme.

Actual Behavior

Fatal error in backend and frontend after activating the theme.

Relevant Log Output

/srv/www/web/app/themes/sage10/vendor/roots/acorn/src/Roots/Acorn/Application.php on line 124

The /srv/www/web/app/cache/acorn/framework/cache directory must be present and writable.

Versions

Remove config and bootstrap directories (#2839)

encodiaweb commented 2 years ago

I have temporary solved deleting the ./cache folder entirely

QWp6t commented 2 years ago

Delete app/cache/acorn. That's the solution.

We'll make sure to add this to the release notes as a migration step.

strarsis commented 2 years ago

@retlehs; @encodia; @QWp6t: So when the theme runtime (acorn library) detects that no app/cache/acorn directory is present, it will automatically create the whole directory structure, including app/cache/acorn/framework and app/cache/acorn/framework/cache?

But when just the app/cache/acorn directory is present, it will not automatically create these, but rather throw an exception. Though *nix philosophy is to fail early and loud and such, IMHO the theme should try to be more "self-healing"/robust here and just ensure automatically that all those required directories are created. – Or would this have unintended consequences?

purplefeel commented 2 years ago

@retlehs Thanks for the great work. I am installing a new project on the latest main branch. I found you added a commit regarding zero-configuration which removes the config directory entirely. Is there a way to override the configurations which are under the /vendor/roots/acorn/config/*.php? I tried to do the old way like creating the /config folder under the theme, it throws an error.

Fatal error: Uncaught Exception: Unable to load the "app" configuration file. in /Users/.../wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php on line 67
retlehs commented 2 years ago

@purplefeel https://github.com/roots/acorn/issues/161

Twansparant commented 2 years ago

I've got the same issue... I would like to have these config files in my theme root as well, otherwise they will get lost on each deploy

retlehs commented 2 years ago

yep we'll get that fixed :+1: but let's keep things on topic so that this issue stays related to the original one reported

the config bug can be discussed over at the acorn bug linked above, please add your comments over there

Twansparant commented 2 years ago

Sorry about that! 🤭

ahmedch1 commented 1 year ago

I have the same problem , do anyone has a solution , I want to change the cache location