Unable to deploy site WP-CLI because of Dotenv error

I’m getting the below error on a freshly provisioned server when attempting to run the deploy script.

I’ve tried changing the composer version to various versions including 1.9-dev. The latest version I had used is 1.8.2.

Looked at these threads (nothing has helped):

Any help would be appreciated!

TASK [deploy : WordPress Installed?] **********************************************************************************************************************************************************************************************
    System info:
      Ansible 2.4.0.0; Darwin
      Trellis 1.0.1: January 16th, 2019
    ---------------------------------------------------
    non-zero return code
    PHP Fatal error:  Uncaught TypeError: Argument 1 passed to
    Dotenv\Dotenv::__construct() must be an instance of Dotenv\Loader, string
    given, called in
    /srv/www/allureprojects.com/releases/20190124205339/config/application.php on
    line 17 and defined in /srv/www/allureprojects.com/releases/20190124205339/ve
    ndor/vlucas/phpdotenv/src/Dotenv.php:31
    Stack trace:
    #0 /srv/www/allureprojects.com/releases/20190124205339/config/application.php
    (17): Dotenv\Dotenv->__construct('/srv/www/allure...')
    #1 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1150) :
    eval()'d code(7): require_once('/srv/www/allure...')
    #2 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1150):
    eval()
    #3 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1111):
    WP_CLI\Runner->load_wordpress()
    #4 phar:///usr/bin/wp/vendor/wp-cli/wp-
    cli/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLI\Runner->start()
    #5 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(74):
    WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\Boots in /srv/
    www/allureprojects.com/releases/20190124205339/vendor/vlucas/phpdotenv/src/Do
    tenv.php on line 31
    fatal: [104.236.36.135]: FAILED! => {"changed": false, "cmd": ["wp", "core", "is-installed", "--skip-plugins", "--skip-themes", "--require=/srv/www/allureprojects.com/shared/tmp_multisite_constants.php"], "delta": "0:00:00.164171", "end": "2019-01-24 20:54:17.761946", "failed": true, "failed_when_result": true, "rc": 255, "start": "2019-01-24 20:54:17.597775", "stderr_lines": ["PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Dotenv\\Dotenv::__construct() must be an instance of Dotenv\\Loader, string given, called in /srv/www/allureprojects.com/releases/20190124205339/config/application.php on line 17 and defined in /srv/www/allureprojects.com/releases/20190124205339/vendor/vlucas/phpdotenv/src/Dotenv.php:31", "Stack trace:", "#0 /srv/www/allureprojects.com/releases/20190124205339/config/application.php(17): Dotenv\\Dotenv->__construct('/srv/www/allure...')", "#1 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1150) : eval()'d code(7): require_once('/srv/www/allure...')", "#2 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1150): eval()", "#3 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1111): WP_CLI\\Runner->load_wordpress()", "#4 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLI\\Runner->start()", "#5 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(74): WP_CLI\\Bootstrap\\LaunchRunner->process(Object(WP_CLI\\Bootstrap\\Boots in /srv/www/allureprojects.com/releases/20190124205339/vendor/vlucas/phpdotenv/src/Dotenv.php on line 31"], "stdout": "", "stdout_lines": []}

Using the latest versions of Bedrock and Trellis?

What does your composer.json look like?

Have you tried rm composer.lock && composer install to make sure your lockfile is up-to-date?

I’m not using the latest version of Bedrock, but I am using the latest Trellis.

The composer.json committed to the repo was generated from the latest stable version of composer (1.8.x).

I’ve tried SSH’ing into the remote server and deleting composer.lock and running composer install – this does work. After doing this, I tried redeploying and still gives that error.

Please show us the actual contents…

Sorry, I misread before.

Here is the composer.json: https://gist.github.com/allurewebsolutions/d1484d7b6a1f5a3977e400809cec5134

Can you reproduce with the latest Bedrock composer.json, without any other changes?

I’m expecting not, in which case you should be able to then compare the two files and hopefully fix your problem

That solved it. Thank you so much!

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