Roots Discourse

Env.php errors with Sage 10 on older Multisite Network

I can’t find a solution to this problem anywhere.

I am attempting to get a new Sage 10 dev-master theme running on an older multisite network as a new sub-site and I am getting all the errors below when that theme is active.

The multisite network is roughly a year old.

Fatal error: Uncaught Error: Call to undefined method Dotenv\Repository\RepositoryBuilder::createWithDefaultAdapters() in /srv/www/ Stack trace: 

#0 /srv/www/ Illuminate\Support\Env::getRepository() 

#1 /srv/www/ Illuminate\Support\Env::get('APP_CONFIG_CACH...')

#2 /srv/www/ Illuminate\Foundation\Application->normalizeCachePath('APP_CONFIG_CACH...', 'cache/') 

#3 /srv/www/ Illuminate\Foundation\Application->getCachedConfigPath() 

#4 /srv/www/ in /srv/www/ on line 55

No problems installing a fresh Sage 9 theme.

This appears to be a similar issue. Not sure what I need to update with Bedrock to help me out.

Anyone have any ideas?

Have you updated to latest Bedrock for that site?

Hi, I’m not completely sure I know how to upgrade Bedrock. Can you explain or point me to some docs that describe that?

So my approach to updating Bedrock is the following:

  1. Create a new, empty Bedrock project using composer: composer create-project roots/bedrock
  2. (Ensure your project already got Version Control like git) Overwrite the existing Bedrock files with the ones of that newly created, empty Bedrock project.
  3. Use Version Control, the composer.json is probably the only file that requires intervention (as it contains metadata (author, etc) and required WordPress plugins, etc.). I remove the composer.lock because i consolidate all plugin versions anyway at that point and re-generate it new using composer update.

I will give it a try and report back!

Much appreciated.

Ok, so here’s what I did.

  1. Renamed site folder to
  2. Ran composer create-project roots/bedrock site to create new bedrock site folder
  3. Opened finder and copied new site directory overtop and replaced files
  4. Removed site folder and renamed back to site
  5. Deleted composer.lock from site directory
  6. Copied my composer.json from my github repo over the new composer.json and ran composer update from the site directory. The update completed without issue.
  7. Ran composer create-project roots/sage new-site dev-master to install Sage 10.
  8. Attempted to visit wp-admin to activte theme and I am receiving the same errors originally posted above.

So I investigated a bit (I also have similar issues when updating themes from time to time).

The Sage 10 theme dependency expects the static method RepositoryBuilder::createWithDefaultAdapters being present (./web/app/themes/sage10/vendor/vlucas/phpdotenv/src/Dotenv.php).
This is provided by a Bedrock site dependency:

So when in your current setup Sage 10 is unable to find RepositoryBuilder::createWithDefaultAdapters, it is missing from the Bedrock site.

Is there a ./vendor/vlucas/phpdotenv/src/Repository/RepositoryBuilder.php in your current Bedrock site?
Does it provide the static method createWithDefaultAdapters?

I suspect that something went wrong while installing the Bedrock dependencies via composer or a caching related issue (opcache file invalidation disabled or incomplete).

What is also striking is that Bedrock and Sage both use vlucas/phpdotenv (they are both required/included by PHP and present during runtime, loading order may matter) - and as the Bedrock site and the Sage theme both use a separate set of composer.json/composer.lock files, composer can’t enforce a single package version.

Thanks for your investigating! I will check it out and report back!

These two steps probably prevented you from getting the necessary updates.

The new composer.json is almost certainly the source of an upgraded package that provides the code that’s expected by Sage 10 and throwing your error. You should compare the composer.json in up-to-date bedrock and update your composer.json to match or exceed the package versions defined there.

This topic was automatically closed after 42 days. New replies are no longer allowed.