Plugin could not be deleted due to an error: Could not fully remove the plugin(s) my-plugin/my-plugin.php

Why uninstalling the following (empty) plugin results in error?

Here is my-plugin/my-plugin.php:

Read More
<?php
/*
Plugin Name: My Plugin
*/

and my-plugin/uninstall.php:

<?php

When I click ‘Delete’ and then confirm, I get the following error:

Plugin could not be deleted due to an error: Could not fully remove
the plugin(s) my-plugin/my-plugin.php.

What’s wrong here?


~/Sites/wordpress/wp-content/plugins/my-plugin $ ls -ll
total 16
-rwxrwxrwx@ 1 me  staff  34 13 Aug 21:43 my-plugin.php
-rwxrwxrwx@ 1 me  staff   6 13 Aug 21:44 uninstall.php

Related posts

Leave a Reply

3 comments

  1. As I posted here:

    It could be a result of either local file permissions or WordPress configuration.

    To fix local file permissions, you can either:

    • If you have root shell access (such as on a VPS server) you can run something like:

      sudo chown www-data:www-data * -R 
      sudo usermod -a -G www-data YOUR-USERNAME-HERE
      

      This ensures that the web server is given access to the “group” permissions.

    • Change the file and directory permissions to 775 (or 777 if that fails) so that PHP can write to the necessary files/folders. For best security (especially if you’re on a shared host), some recommend only doing this temporarily for performing updates and then removing the write permissions again afterward.

    More rarely, this error can also occur if your WordPress configuration in /wp-config.php is set to use something like:

    define( 'FS_METHOD', 'ftpext' );
    

    This tells WordPress that it needs to use FTP to make file changes instead of working directly with the local file system. The line will likely be followed by FTP login information. If this login information is incorrect then WordPress will be unable to login and perform file-system changes.