Categories
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. The migration seemed to work fine. All my articles appeared. All my images appeared. I felt a I had achieved 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 hear.

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 figured 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!!!

First 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. How to name it is way beyond this article.

sudo usermod -aG www-data $USER

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.

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.

find /path/to/site/ -type d -exec chmod 775 {} \;

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.

More about using exec with find

Categories
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