Misha Moroshko
Misha Moroshko

Reputation: 171359

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:

<?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

Upvotes: 9

Views: 20843

Answers (3)

Prabhat
Prabhat

Reputation: 81

This worked for me:

  1. chmod 777 -R <yourfilename>

  2. Adding define('FS_METHOD', 'direct'); to the wp-config.php file

Upvotes: 4

Simon E.
Simon E.

Reputation: 58490

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.

Upvotes: 5

Misha Moroshko
Misha Moroshko

Reputation: 171359

Indeed, ownership problem. After running the following I could delete the plugin successfully.

chown -R <myself>:<myself> my-plugin

Upvotes: 6

Related Questions