Skip to content

Failed to create cache directory (permission denied) #361

In review
wp-cli/wp-cli
#6479

Description

@mvl22

Since the release of 3.0.0, we are seeing this error appearing every time our cli to verify checksums is run:

$ cd /path/to/wordpress-installation/ && sudo -u www-data wp core verify-checksums
Warning: Failed to create directory '/var/www/.wp-cli/cache/': mkdir(): Permission denied.
Success: WordPress installation verifies against checksums.

The installation is not at /var/www/ so it's not clear why wp cli is trying to write there.

Activity

  1. added
    command:core
    status:unconfirmed
    on Dec 2, 2026
  2. swissspidy commented on Dec 2, 2026

    @swissspidy
    Member

    Thanks for the report!

    /var/www is www-data's home directory. Since you are using sudo -u www-data to run a command as that user, this sets HOME to that user's home.

    WP-CLI uses the $HOME/.wp-cli/cache directory for caching all sorts of things. Since WP-CLI v3.0.0 (wp-cli/wp-cli#6424), it caches checksums to speed up later checks. The check itself isn't affected by this warning, the cache just gets skipped.

    To fix this, either create that cache directory, or point WP-CLI to use a different directory, e.g. using sudo -u www-data env WP_CLI_CACHE_DIR=/tmp/wp-cli-cache wp core verify-checksums

    We'll consider turning this particular warning into a debug message in the meantime, but generally speaking I really recommend setting up that cache directory.

  3. changed the title [-]Failed to create directory '/var/www/.wp-cli/cache/': mkdir(): Permission denied - for Wordpress installation in a different directory[/-] [+]Failed to create directory '/var/www/.wp-cli/cache/': mkdir(): Permission denied - for WordPress installation in a different directory[/+] on Dec 2, 2026
  4. mvl22 commented on Dec 2, 2026

    @mvl22
    Author

    /var/www is www-data's home directory.

    Doh, of course, yes.

    Agree having this silently work without a cache is sensible.

    Will a debug message be excluded when using --quiet (as we are)?

  5. swissspidy commented on Dec 2, 2026

    @swissspidy
    Member

    Yes debug messages are excluded by default (even without --quiet) unless you explicitly pass --debug

  6. changed the title [-]Failed to create directory '/var/www/.wp-cli/cache/': mkdir(): Permission denied - for WordPress installation in a different directory[/-] [+]Failed to create cache directory (permission denied)[/+] on Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcommand:corestatus:unconfirmed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions