Recently, when attempting to update some plugins and themes on my WordPress installation, I can across two errors:
Failure Updating Plugins
An error occurred while updating <plugin name>
Failure Deleting Plugins
Plugin could not be deleted due to an error: Could not fully remove the plugin(s) my-plugin/my-plugin.php
The root of the problem is that same: permissions. I’ve found two ways to correct this if your WordPress website is hosted on a Linux server and you have shell access.
This error and solution is the same for WordPress themes too.
- Update the plugins or themes using WP-CLI
- Run a Linux command
Update Plugins or Themes with WP-CLI:
WP-CLI is a command line interface for Linux that allows you to complete WordPress tasks and functions using the Linux command line. This can be faster than completing the same many functions tasks within the WordPress Dashboard.
Built into WP-CLI is the ability to update plugins, themes, and even the core WordPress installation from the command line. This circumvents the problem because there are no interfaces with a browser, and therefore no need for the actual web server (usually Apache) getting involved.
- Install WP-CLI or use a host that has it installed by default like a2 Hosting.
- Run wp plugin update or wp theme update.
However, this is not a permanent solution. But learning the WP-CLI and creating scripts can increase the speed of completing WordPress functions.
Run a Linux Command
This is the best option because we’re actually fixing the problem.
sudo chown -R www-data /path/to/plugin
Replace “/path/to/plugin” which is usually something along the lines of /var/www/html/wp-content/plugins/ewww-image-optimizer, which was an example of the problem I faced.
This will give ownership of the directory back to Apache so that when you update the plugin again through WordPress’s update features, it should work permanently.
These are two great ways in which to correct the ownership issues with WordPress plugin and theme updates. While option 2 is clearly the permanent solution, updating using an automated script found in option 2 might be more helpful if you want to save time maintaining your WordPress website.