Failed to open Stream: wp-includes/template-loader.php

Just spun up a fresh install of everything, when I ran vagrant up my localhost returns the following error/warning:

Warning: include(/srv/www/jackalopemedia.com/current/web/app/themes/./index.php): failed to open stream: No such file or directory in /srv/www/jackalopemedia.com/current/web/wp/wp-includes/template-loader.php on line 74

Warning: include(): Failed opening '/srv/www/jackalopemedia.com/current/web/app/themes/./index.php' for inclusion (include_path='.:/usr/share/php') in /srv/www/jackalopemedia.com/current/web/wp/wp-includes/template-loader.php on line 74

Here’s the repo.

I vagrant sshd into my VM and found template-loader.php and confirmed it there. I believe this is the line of code in question.

I also tried destroy/up multiple times. Keeps repeating the error. Anyone have any ideas?

Note: Probably irrelevant, but this is the first time I’ve installed Sage via composer instead of git cloning.

Thanks, this could be a Sage 9 bug. We’ll take a look into it.

1 Like

https://github.com/roots/sage/blob/master/src/filters.php#L53

Change that to…

    return dirname(__DIR__) . '/index.php';

I think that should do the trick. If that doesn’t work, then it has something to do with the manipulation I’m doing in functions.php.

Thanks!

I replaced that line in filters.php, and I was getting just a blank page on my dev url.

So I vagrant destroyed/up’d again, and same thing. Hopefully I’m not missing a step.

I’ve re-spun up a fresh install, and I’m still getting the exact same php error as in post #1 (to the exact line of code).

I’ve gone over the docs a few times each to make sure I haven’t missed a new step that was added.

The only steps I see that confuse me:

  1. Copy .env.example to .env and update environment variables

    • I’ve never done this step, and it seems Trellis may be automatically populating .env for me.
  2. Set your site vhost document root to /path/to/site/web/ (/path/to/site/current/web/ if using deploys)

    • I don’t usually do this either. I’m assuming when I use Trellis/Bedrock/Sage w/ DigitalOcean it’s done by default.

Since I’ve successfully spun up Roots sites without doing these, I’m going to assume they’re unrelated. Every other step seems to be done.

@swalkinshaw & @QWp6t– is this still considered a possible bug? Anything I can do to help meanwhile?

I’m not the best person to answer the Sage stuff, but those 2 steps you mentioned for Bedrock are indeed taken care of automatically by Trellis.

1 Like

Cool, thanks for the update! I’m just confused because I thought if it was a bug, other people would be experiencing it too.

I wonder what’s the likelihood of it being related to me recently upgrading my macbook to PHP7.1.

How did you install Sage? With or without Composer? If without Composer, did you skip running composer install?

It was my first time using Composer to download it instead of Git Clone. So I just ran composer create-project roots/sage sage dev-master.

By “just ran” do you mean just now, or prior to you posting this thread?

Your issue shouldn’t exist if you installed Sage with Composer (or just ran composer install) and then activated the theme

Thanks Ben. By “just ran”, I mean installed Sage using the create-project Composer command prior to posting this thread. I hadn’t yet run composer install. If I do run composer install (just now inside web/app/themes/sage), I get:

Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Nothing to install or update Generating autoload files

I’m assuming that’s expected.

Decided to clone down your repo and see what’s up. Here’s what broke it:

You removed the Bedrock mu-plugin for registering a default theme directory, then set Sage as your default theme in your application.

This won’t work with Sage 9 as its dependent on being “activated” or switched to from a different theme initially.

So if you want to get Sage 9 running:

  1. Remove define('WP_DEFAULT_THEME', 'sage');
  2. Re-add the Bedrock mu-plugin for default themes, or just switch to any other theme
  3. Then activate Sage
2 Likes

Everything’s working as usual now. I guess I’m better at spotting when new steps are added rather than removed. I’d be interested if anyone has any tips for spotting obsolete steps easier, I’m all ears. I’d just become accustomed to doing that each time.

Thanks for taking the time to do that Ben! I’m stoked to be up n running w/ Sage9 now! :slight_smile: