sebthom.de

Menu
  • Home
  • About me
  • Imprint
    • Datenschutzerklärung
  • Guestbook
Menu

[Solved] WordPress 2.5 One-Click Plug-in Upgrades – Could not create directory

Posted on 2008-04-252013-06-23 by sebthom

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 one-click plug-in upgrade 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.

  1. Locate and open the file <wp_root>/wp_admin/includes/class-wp-filesystem-direct.php in an editor
  2. Search for “function mkdir”
  3. Add the following statements to this method
    function mkdir($path,$chmod=false,$chown=false,$chgrp=false){
    	if( ! $chmod)
    		$chmod = $this->permission;
    
    	// workaround for //bugs.php.net/bug.php?id=42739 starts here
    	if(ini_get('safe_mode') && substr($path, -1) == '/')
    	{
    		$path = substr($path, 0, -1);
    	}
    	// workaround for //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;
    }
  4. Start one-click updating!

Update 1:

  1. The patch also works for WordPress 2.5.1
  2. 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:

  1. In case the patch does not work check if you have the AskApache Password Protect plug-in installed.
  2. If so, try to deactivate this plug-in before you try to upgrade any other plug-in.

42 thoughts on “[Solved] WordPress 2.5 One-Click Plug-in Upgrades – Could not create directory”

  1. Brent Rasmussen says:
    29 April 2008 at 4:17 PM

    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!

  2. Martin Hiegl says:
    29 April 2008 at 8:59 PM

    Many thanks! Works great for me. I think that’s the first time WordPress didn’t work with safe mode properly.

  3. aouni says:
    29 April 2008 at 11:40 PM

    Thank you man. It worked!

  4. Kevin Jarrett says:
    30 April 2008 at 4:15 PM

    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…

  5. Pingback: SirViejo » Soluciones a problemas en Wordpress 2.5.1
  6. Noel says:
    14 May 2008 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.

  7. Matthew Jabs says:
    15 May 2008 at 9:32 PM

    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.

  8. Rafael Arcanjo says:
    16 May 2008 at 2:18 AM

    Great !!!

    Thanks Sir!

  9. vdias says:
    16 May 2008 at 9:26 PM

    777 its a bit dangerous…

  10. Wanderer says:
    28 May 2008 at 1:45 PM

    Hey, your solution worked! Thanks a lot!

  11. Marek says:
    29 May 2008 at 7:55 AM

    Ey Kollege bei mir hat das Upgrade problemlos funktioniert. Vielleicht sind ja die PHP-Einstellungen deines Provides etwas restriktiver?

  12. Pingback: Plugins no Wordpress: Could not create Directory
  13. racoon97 says:
    27 June 2008 at 1:25 AM

    Thank you so much. Easy update for plugins works now.

  14. Chris says:
    15 July 2008 at 12:56 AM

    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!

  15. Andreas says:
    17 July 2008 at 12:58 AM

    Bin begeistert – es funktioniert danke dieser “Slash” Lösung

  16. sanadi says:
    17 July 2008 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’;

  17. Cynthia says:
    3 December 2008 at 1:47 AM

    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!

  18. Stephen says:
    10 December 2008 at 11:07 PM

    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!

  19. Pingback: WordPress 2.7 "Coltrane" Brings You to Wonderful Automatic World | M B L 0 G G E R
  20. rivermaya says:
    29 December 2008 at 9:45 PM

    if you can’t change permission for upgrade directory, just delete the files inside it and try again to chmod

  21. Liew Cheon Fong says:
    21 January 2009 at 10:27 PM

    does not work on wordpress 2.7

  22. Jimisola says:
    13 March 2009 at 10:24 PM

    Thanks. patch + chmod did the works! (WP 2.5.1)

  23. turkyjulio says:
    16 July 2009 at 5:25 AM

    Thanks a lot, it not just work for WP 2.5 but also WP 2.8. It’s totally helping me…..Gracias.

  24. Ben says:
    18 September 2009 at 4:18 PM

    Thank you SO MUCH – I had tried several solutions.

    You are the one who nailed it, thanks again 🙂

    Ben

  25. Trisya says:
    12 November 2009 at 7:27 AM

    it worked!!! thanks alot!! 😀

  26. tijms says:
    28 November 2009 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.

  27. Anthony says:
    26 March 2010 at 8:57 AM

    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).

  28. shawn says:
    4 June 2010 at 4:06 PM

    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.

  29. Symmtech says:
    17 June 2010 at 4:13 AM

    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.

  30. Symmtech says:
    17 June 2010 at 4:28 AM

    The difference in the /etc/vsftp.conf files was

    # Uncomment this to enable any form of FTP write command.
    #write_enable=YES

    The 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.

  31. umair says:
    4 December 2010 at 12:40 PM

    im on 3.2 and nothing works for me

  32. tonyawards says:
    5 December 2010 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!

  33. progone says:
    5 January 2011 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

  34. Panks says:
    6 July 2011 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.

  35. Caleb Madrigal says:
    29 August 2011 at 4:59 AM

    Symmtech, Thank you for posting your solution! I had the same problem issue.

  36. Zaadu says:
    2 September 2011 at 6:17 AM

    I’m having issue with wordpress 3.2.1 what to do

  37. Sebastian Thomschke says:
    21 May 2012 at 12:01 AM

    For WordPress 3 or later check if the AskApache Password Protect is installed and deactivate it.

  38. Pingback: Miguel Nunes aka spacemig » Blog Archive » Wordpress permissions problems
  39. Adrian says:
    24 November 2012 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.

  40. Carly says:
    2 January 2013 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?

  41. Sagen says:
    7 March 2013 at 9:24 PM

    Oddly enough I had this problem for the very first time with WP 3.5.1 on one of my websites [not the one listed with my information] (but not on any of my other WP sites on the same host).

    I don’t have safe_mode turned on in php.ini, so the mkdir work around would be pointless to implement (I checked multiple times to make sure safe_mode wasn’t on) and I even checked the chmod for the plugins folder (it was already 777).

    I had a suspicion it was probably the cause and used the suggestion given in the comments by the original poster about AskApache Password Protect (disabled it).

    Then I ran the update for that plugin and then re-activated it and then tried to update the other update-pending plugins and theme.

    Now everything is working perfect again and I can continue to work on the site!

    Thanks, Sebastian!

  42. Jacob Schooley says:
    12 March 2013 at 3:46 PM

    I was able to get plugins installing this way, and I would never had thought of it. I changed the file, then I cd’ed to /srv/www/wp-content and used sudo chmod -R 777 on localhost.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Language

    English English    Deutsch Deutsch    

Categories

  • IT (25)
    • Development (15)
      • Java (7)
      • Jython (3)
      • Visual Basic (5)
    • Freeware Tips (1)
    • Linux (3)
    • WebSphere Portal (2)
    • Windows (1)
    • Wordpress (4)
  • My Freeware (2)
  • My Music (3)

Recent Posts

  • [Solved] Windows 7 “Safely Remove Hardware” pop-up menu horrendously slow
  • Bash: Capturing stderr in a variable while still printing to the console.
  • Configuring EMF Teneo with Hibernate, Commons DBCP, Spring Hibernate Transaction Manager, and the OpenSessionInViewFilter
  • Using EMF ECore model objects with Wicket components
  • Installing Tomcat 6 on Debian Squeeze
  • Leveraging PyDev’s auto-completion for indirectly created objects
  • OVal 1.40 released
  • Installing WebSphere Portal in a local network
  • Comparing version numbers in Jython / Python
  • Running TomCat 6 in Debug Mode under Windows

Blogroll

  • E L S U A
  • elektrofever.de
  • OVal
  • Sweettt.com
  • Twins’ Running Blog

Recent Comments

  • Luis Diego Villarreal on Excel – VBA Timer Example v1.0.1
  • jonathan on Guestbook
  • Pierre on Lotus Notes’ [Send only] and [Send and File] buttons for Outlook 2003
  • Yereverluvinunclebert on MyPad v1.1.6 – a PHP Editor
  • Sebastian Thomschke on MyPad v1.1.6 – a PHP Editor

Archives

  • May 2012
  • January 2011
  • October 2010
  • September 2010
  • March 2010
  • February 2010
  • September 2009
  • July 2009
  • March 2009
  • February 2009
  • November 2008
  • September 2008
  • May 2008
  • April 2008
  • September 2007
  • July 2007
  • July 2004
  • March 2003
  • August 2002
  • April 2002
  • January 2002
© 2021 sebthom.de | Powered by Minimalist Blog WordPress Theme