Only see blade template updates after running `wp acorn view:cache`

This is my first time using Sage, but I’ve been using Trellis and Bedrocks lots. The site that I’m working on right now is an old one. I’m planning to migrate the theme to Sage 10. The site doesn’t use Bedrock.

I have a clean Sage 10 theme and I’ve installed Acorn with Composer (in the theme directory). When I try to load a page, I got an error, but I can’t find it in my logs anymore.

When I ran wp acorn view:cache, it loads a very basic page with my primary navigation. Whenever I make a change to index.php and I refresh, I see my change.

But when I make a change to one of the blade templates, it doesn’t show when I reload the page. Only if I run wp acorn view:cache does it show the change.

I thought it had something to do with my environment, since when I ran wp acorn env it showed that I’m running a production environment. I’ve added define('WP_ENV', getenv('WP_ENV') ?: 'development'); to my wp-config.php, and now it show that my environment is set to development. This didn’t make a difference.

When I run wp acorn view:clear, I get a fatal error:

[Tue Mar 15 14:32:29.172723 2022] [php7:error] [pid 180719] [client] PHP Fatal error:  Uncaught Illuminate\\Contracts\\Filesystem\\FileNotFoundException: File does not exist at path /var/www/site/wp-content/cache/acorn/framework/views/1b027eb7a7a5e59758da6ceca13ea9fb5d46fb01.php. in /var/www/site/wp-content/themes/site-sage/vendor/illuminate/filesystem/Filesystem.php:111\nStack trace:\n#0 /var/www/site/wp-content/themes/site/vendor/illuminate/view/Engines/PhpEngine.php(58): Illuminate\\Filesystem\\Filesystem->getRequire()\n#1 /var/www/site/wp-content/themes/site-sage/vendor/illuminate/view/Engines/CompilerEngine.php(61): Illuminate\\View\\Engines\\PhpEngine->evaluatePath()\n#2 /var/www/site/wp-content/themes/site-sage/vendor/illuminate/view/View.php(139): Illuminate\\View\\Engines\\CompilerEngine->get()\n#3 /var/www/site/wp-content/themes/site-sage/vendor/illuminate/view/View.php(122): Illuminate\\View\\View->getContents()\n#4 /var/www/site/wp-content/themes/site-sage/vendor/illuminate/view/View.php(91): Illuminate\\View\\View->renderContents()\n#5 /var/www/site/wp-conten in /var/www/site/wp-content/themes/site-sage/vendor/illuminate/filesystem/Filesystem.php on line 111

Any ideas what I’m doing wrong? Thanks!

My first thought is that there’s an issue with your filesystem and/or potentially whatever you’re using to create your dev environment (i.e. your VM, docker container, etc). Blades should be automatically regenerated on load when necessary–wp acorn view:cache is mostly for deploying to infrastructure that prevents that so blade need to be pre-generated: On local development you shouldn’t need to do that.

What is your development environment? i.e. Are you using VirtualBox? Docker? Local? Valet? Something else?

It’s just Apache2 on my Ubuntu 20.4 desktop. Really nothing special. Normally I use Bedrock and Vagrant, and I’m not that familiar with configuring web servers, so maybe I have something misconfigured. The old theme seems to load without any issues though.

It actually was a filesystem/ownership issue. My user is the owner of all the files, including the wp-content folder that Illuminate is trying to create a cache/ folder in. I thought if my user was part of the www-data group, files that I’m the owner of can also create directories, but apparently that’s not the case. I needed to chown www-data:www-data wp-content to give ownership to Apache.

It works, but I think this probably could be done without changing ownership of the wp-content folder. If you read this and you know a better way, I’d appreciate it if you’d share it.