28

Dec

Fix for WordPress “Could not remove the old plugin” error

Posted by jerry as Uncategorized

I had been seeing the error “Could not remove the old plugin” any time I tried to auto upgrade a plugin.  A search of the wordpress forums revealed that this is apparently a common problem that does not appear to impact everyone, and there isn’t a known fix.  The error looked like this:

Downloading update from http://downloads.wordpress.org/plugin/related-posts.zip

Unpacking the update

Deactivating the plugin

Removing the old version of the plugin

Could not remove the old plugin

Plugin upgrade Failed

So, I spent some time last night trying to find out what the problem was.  As it turns out, some upgrade or plugin along the way created a bunch of nested wp-content directories.  It looked list this:

/home/mydir/public_html/wp-content/wp-content/wp-content/wp-content/wp-content/wp-content/plugins

The filesystem driver code in wordpress doesn’t handle this very gracefilly.

It turns out that the fix needed is to delete the extra wp-content directories.

rm -r /home/mydir/public_html/wp-content/wp-content

works quite nicely.  After deleting this directory, rerun the auto upgrade and it should complete successfully.

NOTE:  You should make a back up before you perform the above operation.  Deleting the wrong directory will result in a dead site.

Leave a Comment:

You must be logged in to post a comment.