Web Development

WordPress : Update failed: The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.

So you got this error when trying to update one of your plugins or upload an image or something else?

I was confused by this message right after creating a new wordpress website and then migrating my content.

I did a bad, bad no, no while updating and lost the entire site, so I had to start again from a bakcup. Yes I have lost this entire site. Thank god for backups. You’d be amazed how quickly you learn when you have no other choice. LOL. I highly suggest jetpack backups. The cheapest jetpack package is all I have and it is AMAZING.

The migration seemed to work fine. All my articles appeared. All my images appeared. I felt I had achieved a great success.

borat great success meme
I had a great success. NOT!!!

Then I tried to write an article and add an image. I got a failed to upload image message. The odd thing is I could go to old articles and still upload images.

WTF is going on here
So why doesn’t this work?

I thought that was weird. Then I got a notice in my dashboard that a plugin needed updating. I tried to update it and got the error that lead you here.

I was lazy and ignored it a few days, thought it was just the plugin. Then another plugin needed updating. When I tried to update it I got the error again.

Update failed: The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.

I’ve done a lot of server admin work so I knew it was a simple permission issue. The only problem I had no idea what directories/folders needed permission changes and what they needed to be.

So I did a little research.

Doing Research!!!

And the reason the name of this article is so long? Because nothing I typed matched a damn thing and I figured someone would be having this issue soon. LOL

You will need to login to your server either with SSH or many hosting companies now have a way to open a terminal right in your user interface.

First you will need to update the user permissions with usermod. After this your files owner and group will be something like www-data that is what my server (Nginx) was named. Here is a link to how to find out what yours is named.

sudo usermod -aG www-data $USER

The above line adds your current user to your servers group (Apache/Nginx). More on that here on Stackexchange if you look for the above command in the answers.

If you need to know where your wordpress is installed type the following using find command again.

find -name wordpress

That command will output something like /var/www/html/…/…/…/wordpress  It finds anything with the name wordpress.

Next set the permissions on the files under your wordpress directory. Mine was located at /var/www/html/ so I used.

find /var/www/html/ -type f -exec chmod 664 {} \;

This uses the find Linux command and exec with chmod command. Basically this line of code is using the find command to find all the files (f) in the directories in or below /var/www/html/ and it applies chmod to them with permissions of 664. This means the owner and group have the read/write permissions but other users can only read. No one has the execute permissions not even root because this could cause security issues.

Next you need to change the directory permissions so that wordpress plugins can write to them and images can be uploaded etc. This will use the find command too, but slightly different syntax. This time use a d to find the directories in or below /var/www/html/ like so. Again your path may differ

find /var/www/html/ -type d -exec chmod 775 {} \;

I think I originally tried something more restrictive than 775 and something failed. Like something during a plugin update needs to have that permission level to work. 775 means the owner and groups can read/write and execute. I’ll be working on this again soon and see if I can get the permissions tighter and update this article.

That should make your wordpress work. Your site may be located in a directory different from /var/www/html/ you will need to look in your Server (nginx/apache) settings for the root directory or use the find -name wordpress command shown. That is where the permissions need changing. This all depends on who installed your wordpress, but I believe the above is default.

More about using exec with find

cool stuff meme
Cool stuff man.
Resources Web Development

Web Development resources

Media queries you should know about

Browser support for Javascript API’s – This is a very useful table to see what is supported at the moment

Link to ecmascript feature tables to look up what you can use in Javascript in current browsers.

Transaction patterns for web applications – interesting article with good information.

Must-Have Social Meta Tags for Twitter, Google, Facebook, & More 

opendyslexic Font for dyslexic people or anyone in general a good font.

andika nice clear fonts for clean looking text that is easy to read

What You Need to Know About Open Graph Meta Tags for Total Facebook and Twitter Mastery– Very good introduction to the topic, not a long read.

List of all mime types