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.

2 Likes

It depends which environment you mean.
If you ssh into production with trellis trellis ssh production,
you’ll be loged in as admin user. Per default admin user have no permission to import or export db.
So you have to login with web user with ssh web@ip-address.

3 Likes

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