-
[Solved] WordPress 2.5 One-Click Plug-in Upgrades – Could not create directory
Some days ago I upgraded my WordPress installation to the new 2.5 release. Being a lazy guy I of course wanted to use the new on-click plug-in upgrades feature to update several plug-ins. Trying to one-click update some of the out-dated plug-ins only resulted in the rather meaningless error message “Could not create directory”. So I started searching the web for possible solutions. I quickly found some posts explaining this issue to be a directory permission problem. Manually creating the /wp-content/upgrade directory and chmoding it as well as the plug-in directories to 777 should solve the problem. Unfortunately not for me. Therefore I rolled up my sleeves and started to debug WordPress…
To cut a long story short, eventually I came across this PHP bug report #42739 mkdir doesn’t like a trailing slash when safe_mode is enabled and it turned out that this was the issue I was facing with on my hosting account too. The safe_mode option is enabled and WordPress tries to create directories that end with a slash (e.g. /htdocs/wp-content/upgrade/the-plugin/).
After knowing the reason I could develop a workaround and finally got the one-click updater running. If you are facing the same issue you can try to use my patch too.
- Locate and open the file <wp_root>/wp_admin/includes/class-wp-filesystem-direct.php in an editor
- Search for “function mkdir”
- Add the following statements to this method
function mkdir($path,$chmod=false,$chown=false,$chgrp=false){ if( ! $chmod) $chmod = $this->permission; // workaround for http://bugs.php.net/bug.php?id=42739 starts here if(ini_get('safe_mode') && substr($path, -1) == '/') { $path = substr($path, 0, -1); } // workaround for http://bugs.php.net/bug.php?id=42739 ends here if( !@mkdir($path,$chmod) ) return false; if( $chown ) $this->chown($path,$chown); if( $chgrp ) $this->chgrp($path,$chgrp); return true; } - Start one-click updating!
Update 1:
- The patch also works for WordPress 2.5.1
- If applying this patch does not lead to success the problem may have a second cause. Therefore also check the permissions on the /wp-content/upgrade/ folder and it’s sub folders, e.g. chmod them to 777. If the upgrade directory does not exist at all it may be sufficient to create it manually.
Update 2:
- In case the patch does not work check if you have the AskApache Password Protect plug-in installed.
- If so, try to deactivate this plug-in before you try to upgrade any other plug-in.
36 responses to “[Solved] WordPress 2.5 One-Click Plug-in Upgrades – Could not create directory”

-
At first, it still didn’t work for me. Even after adding your workaround code to the ‘mkdir’ function in ‘class-wp-filesystem-direct.php’, I was still getting the “Could not create directory” error while using the automatic upgrade feature for the Akismet plugin.
I figured it was a rights issue still, even after the code was added. I chmodded all the folders down to the plugin folder and plugin file that I wished to upgrade automatically to 777. In other words I chmodded to 777 the, “wp-content” folder, the “plugins” folder, the “akismet” plugin folder, and the”akismet.php” plugin file. After that, I ran the automatic upgrade on the Akismet plugin from Dashboard, and it worked fine. Re-chmodded everything to 755, and I’m done.
Still easier than doing it manually, I suppose.
Thanks for figuring this out!
-
Many thanks! Works great for me. I think that’s the first time WordPress didn’t work with safe mode properly.
-
Thanks but this is not working here. Edited the code, no dice. Changed permissions too, no difference. Must be something else, at least for me…
-
Noel 8:02 PM at 8:02 PM
The ‘could not create directory’ message for me turned out to be an attempt to make a wp-content/upgrade directory. Once I made this with the correct permissions (along with setting perms on the plugin directory) things went fine.
-
This solution didn’t work for me, but changing the writes on the plugins dir & all child dirs (not the files, just all dirs) from 755 to 777 did work.
Thanks.
-
Ey Kollege bei mir hat das Upgrade problemlos funktioniert. Vielleicht sind ja die PHP-Einstellungen deines Provides etwas restriktiver?
-
I’m running on Windows (using XAMP) and creating the directory with appropriate permissions did not work for me, your code hack did though, so, thanks!
-
sanadi 6:58 AM at 6:58 AM
Ich musste \wp-admin\includes\update.php in Zeile 123 ändern, damit es funktioniert:
//$working_dir = $content_dir . ‘upgrade/’ . basename($plugin, ‘.php’);
$working_dir = $content_dir . ‘upgrade’; -
The code hack didn’t work for me, neither did the permissions. Grrr.. i have a number of blogs running on the same host (VPS) and the rest of them work fine!
I did have to create the upgrade subdirectory… that didn’t make a difference either. Bleh!
-
I just tried all of the suggested hacks on my other WP site that’s hosted externally. Unfortunately, nothing worked but that maybe because it’s running WP 2.7 RC1.
Thanks for the tips though!
-
if you can’t change permission for upgrade directory, just delete the files inside it and try again to chmod
-
Thanks a lot, it not just work for WP 2.5 but also WP 2.8. It’s totally helping me…..Gracias.
-
Thank you SO MUCH – I had tried several solutions.
You are the one who nailed it, thanks again
Ben
-
tijms 8:29 PM at 8:29 PM
I had hoped you had solved my problems, but unfortunately the suggested solution(s) didn’t work…
Even if chmodding the directory to 0777 the error remains, despite me using the mkdir fix you suggested.
Does anyone have any idea what might be causing this? Creating directories and copying files remains a problem despite the liberal file/dir attbs set.
-
Thanks! I’ve been having this problem ever since I installed WordPress, and I’m surprised it hasn’t been fixed after three major updates.
However, this fix does it every time, and this is the only website I’ve seen so far that has a legitimate fix. All the other sites just say to chmod the folder to 777 (not a good idea all of the time).
-
If you have a VPS or dedicated server you may also want to use the shell to set the permissions. The reason is UMASK. Just because php sets the permissions doesn’t mean that apache has the rights to that folder due to UMASK.
-
I know this thread is a bit old, but I thought I would post my fix to my problem. I have been searching for weeks trying to find out why I could write to or make directory using wp 2.9.2 ubuntu 10.4 new install. The problem turned out to be in the vsftpd configuration where the local user couldn’t write when posting. I performed a manual ftp and couldn’t post the file using cmd ftp client. I couldn’t write. I then got my vsftpd.conf configuration file from the working (old) server and configured the new server just like the old. After that WP work as always. I will post the difference in the configuration shortly.
-
The difference in the /etc/vsftp.conf files was
# Uncomment this to enable any form of FTP write command.
#write_enable=YESThe new server was configured with the #write_enable=YES commented out like the above. I uncommented it and WP worked.
I use SSH and ftp over ssh mostly and that is why I didn’t notice the ftp write issue earlier.
Hope this helps somebody.
-
tonyawards 9:41 AM at 9:41 AM
Thank you – this finally worked for me after your script and the chmod -R 777 for wp-content, wp-includes, and wp-plugins – as referenced above by you and Brent Rasmussen.
And – this was for WordPress 3.0.2 — still an issue, I guess, But fixed with this procedure. Now I can (finally) upgrade and install plugins locally in my lampp installation
Thanks!
-
progone 6:25 PM at 6:25 PM
I did as you said, and it did get me a step further. Now I get the error.
Could not create directory. /httpdocs
-
Panks 6:03 AM at 6:03 AM
Im on VPS and nothing worked for me. Can someone tell me what can be the issue? It happened to all my websites on VPS.
-
Symmtech, Thank you for posting your solution! I had the same problem issue.
-
Adrian 4:17 AM at 4:17 AM
You’ll never guess what was causing me to get this message? I ran out of disk space on the server
Glad it was easy to fix. -
Carly 3:25 PM at 3:25 PM
This worked like a treat for me. Saved me lots of hassle. I’m guessing I’ll have to add this back in EVERY TIME I update my install of wordpress?
4 Trackbacks / Pingbacks
-
[...] un poco encontre el blog de Sebastian Thomschke que nos da la solucion que encontró en un [...]
-
[...] e continuou da mesma forma. Então, consegui encontrar a solução no sebthom.de A solução para seus problemas pode estar aqui embaixo. Funcionou comigo. Tome [...]
-
WordPress 2.7 "Coltrane" Brings You to Wonderful Automatic World | M B L 0 G G E R 7:14 PM at 7:14 PM
[...] ?????????????? ?????????? ????????? ?????? ???????? ???????? ?????? [...]
-
[...] One-Click Plug-in Upgrades Could not create directory [...]
Leave a reply
- Locate and open the file <wp_root>/wp_admin/includes/class-wp-filesystem-direct.php in an editor

Looking for a high performer for your next IT project?
English
Deutsch
Brent Rasmussen 4:17 PM at 4:17 PM