Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 684
Misha Moroshko Avatar asked Aug 13 '12 11:08

Misha Moroshko


3 Answers

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

chown -R <myself>:<myself> my-plugin
like image 168
Misha Moroshko Avatar answered Oct 21 '22 09:10

Misha Moroshko


This worked for me:

  1. chmod 777 -R <yourfilename>

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

like image 42
Prabhat Avatar answered Oct 21 '22 11:10

Prabhat


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.

like image 29
Simon East Avatar answered Oct 21 '22 10:10

Simon East