Changing the WP CLI cache folder

As a highly concerned hosting company owner I am using WP-CLI to update plugins, themes and wp core of my clients.

Updating WP-Core

find /home/*/public_html -name "wp-admin" -execdir /home/wp core update --allow-root \;

Updating Plugins

find /home/*/public_html -name "wp-admin" -execdir /home/wp plugin update-all --allow-root \;

Updating Themes

find /home/*/public_html -name "wp-admin" -execdir /home/wp theme update-all --allow-root \;

Everything is working extremely well, but I want just to change CACHE folder for WP-CLI since I do not want it to store in /root/wp-cli/.cache

It’s actually not storing anything there because I enabled Open base dir, how can I change location of cache folder for wp cli? is there a syntax? I can’t find any docs on it

PHP Warning:  file_exists(): open_basedir restriction in effect. File(/root/.wp-cli/cache/) is not within the allowed path(s): (/home:/tmp:/opt/cpanel/composer/bin/composer) in phar:///home/wp/php/WP_CLI/FileCache.php on line 261

I honestly do not know what is cache folder used for but since wp cli can’t use it I am just afraid that something will fail, but so far it didn’t.

2 s
2

You could try to change it through the environment variable:

WP_CLI_CACHE_DIR

as we have it included in the WP_CLI::get_cache() method (src):

$dir = getenv( 'WP_CLI_CACHE_DIR' ) ? : "$home/.wp-cli/cache";

You can also check out issue #1848 – Use shared cache directory for multiple installs for usage examples.

In the WP-CLI Handbook on make.wordpress.org, we have a list of environment variables used by WP-CLI.

Leave a Comment