Roots Discourse

WP-CLi - Fatal error

Hi guys, just trying to export db via wp-cli but for some reason if I try to do it with non-root user it’s not working on my server, also seems like inside vagrant everything is ok. Do I must to use --allow-root or there is some workaround for this.
Here is the error:

Fatal error: Uncaught Dotenv\Exception\InvalidPathException: Unable to read any of the environment file(s) at [/srv/www/example.com/releases/20210201104624/.env]. in /srv/www/example.com/releases/20210201104624/vendor/vlucas/phpdotenv/src/Store/FileStore.php:57

Stack trace:
    #0 /srv/www/example.com/releases/20210201104624/vendor/vlucas/phpdotenv/src/Dotenv.php(157): Dotenv\Store\FileStore->read()
    #1 /srv/www/example.com/releases/20210201104624/config/application.php(33): Dotenv\Dotenv->load()
    #2 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1197) : eval()'d code(7): require_once('/srv/www/api.gr...')
    #3 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1197): eval()
    #4 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1158): WP_CLI\Runner->load_wordpress()
    #5 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLI\Runner->start()
    #6 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(74): WP_CLI\Bootstrap\LaunchRunner->p in /srv/www/example.com/releases/20210201104624/vendor/vlucas/phpdotenv/src/Store/FileStore.php on line 57

UPD: fixed by moving folder ownership to the user which execute this command.

1 Like