Roots Discourse

How to update Bedrock? (phpdotenv incompatibility?)

Hello,

I have a bedrock installation made couple of years ago (v.1.12.8 according to CHANGELOG.md, there’s no other place where I can check version number), and recently I wanted to get back to this project :slight_smile: I noticed that upon making updates to some packages/plugins, Composer prompted me to update to version 2, which went just fine.

I wanted to see if the Capistrano deployment still works, and… here’s where the problems started. There were errors on deploy, but I found some threads here which eventually resulted in:

  • bumping composer/installers to ^1.9, in both the project and theme folders
  • bumping vlucas/phpdotenv to ^5.2, which installed v.5.4 which I realised isn’t yet merged, so eventually I downgraded to the latest merged version which is v.5.2.
  • removing “vendor” folder from project and theme folders
  • running “composer install && composer update”

However, now the problem is not with deployment but with the project itself. I am locally getting an error:
Argument 1 passed to Dotenv\Dotenv::create() must be an instance of Dotenv\Repository\RepositoryInterface, string given...

Since I did update the vlucas/phpdotenv package, as described above, but my Bedrock version is from 2019 (1.12.8) – isn’t this the problem?

How do I update Bedrock? If that’s not required, where do I look to fix this?
Thanks!

Have you compared the code in your version of Bedrock to the latest? There are changes that you are required to make based on phpdotenv changes

Searching for the error message you provided came up with this topic which links to a GitHub PR - check out that code diff and make sure that you’ve got that change made to config/application.php

Thanks for your reply!

I can change config/application.php to the state the topic (which I have seen before) was pointing to (link) but now my instance cannot connect to database – showing the typical Wordpress page “Error establishing a database connection”.

I’ve tried using the very latest config/application.php but it creates some more problems – for instance the function Env\env is not recognized, and I clearly am not fluent enough to be able to fix it.

How do I update Bedrock to the latest?

Sounds like you’re missing roots/wp-config and the changes that came with that.

There’s a few different approaches folks use… personally I overwrite all of the files in a project with the latest published release and look at the diff

Thanks, I think I have to update the whole thing as it’s only going to be more confusing…

BTW, I do have web/wp-config.php file, if that’s what you’re referring to, and it looks exactly like the current version.

:+1: Definitely recommend updating the whole thing but hopefully it won’t be too difficult!

This is what I was referring to: New Bedrock Configuration Model by austinpray · Pull Request #380 · roots/bedrock · GitHub

Done, wasn’t that hard after all. Just a handful of files to be checked & updated, really!

I wasn’t sure about one additional mu-plugin (disallow-indexing.php, since I had it but it wasn’t in the original Bedrock package… but after running composer install it is still there and no problems whatsoever.

Deployment with Capistrano wasn’t affected by this update, so I’m happy about it too – tried on staging and eventually updated the production site too.

Thanks a lot @benword!

1 Like