CTools fails to create the 'ctools/css' folder where the css cache is stored on some occasions. (i.e. wrong folder permissions in default/files, different Drupal file system settings, etc.)

When you use a module that depends on CTools (most notably Panels) this translates in this cryptic error:
'Selected file could not be uploaded, because destination is not properly configured' when you are trying to view a panel page.

You can solve the issue by manually creating the directory as described in issue #425446: The selected file ... could not be uploaded, because the destination is not properly configured" error occured

The big issue here is that when CTools fails to create the directory, there's no clear error message that provides a hint what causes the problem. Moreover, users are not pointed to possible solutions (create the folder manually, check your permissions, check file system settings, etc.)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

merlinofchaos’s picture

Status: Active » Fixed

I added some code to make this more robust (Drupal's file API is really difficult to work with) and added a hook_requirements check as well. Hopefully this will take care of these issues.

JayKayAu’s picture

Version: 6.x-1.0-alpha3 » 6.x-1.0-beta2

Hi,

I have CTools (6.x-1.0-beta2) in my installation, and I've just updated my site to the Drupal 6.12 release. When I went and had a look at the status report, it gave the following:

"CTools CSS Cache Unable to create
The CTools CSS cache directory could not be created due to a misconfigured files directory. Please ensure that the files directory is corretly configured and that the webserver has permission to create directories."

To fix it, I did a chmod 777 on these directories:
drupalroot/sites/mysite/files/ctools
drupalroot/sites/mysite/files/ctools/css

I had to dig around on the internet first, then make an educated guess as to the problem. But the error message could have been a teensy bit more helpful, particularly for users with even less experience than me.

EDIT: I just realised that these files were created by the "_www" user, and when I copied the files across, I became the owner, and _www couldn't write the files/directories again. Incidentally, I am using OS X and copied through the Finder (I don't know if doing it that way behaves differently to a "cp" command wrt permissions).

Thanks for an otherwise great package :D

- J

nanatulip’s picture

Status: Fixed » Active

I have the same error message & I also have CTools (6.x-1.0-beta2) in my installation, and I've also just updated my site to the Drupal 6.12 release. When I went and had a look at the status report, it gave the following:

"CTools CSS Cache Unable to create
The CTools CSS cache directory could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories."

The problem is, I am one of those "less experienced" ones that you mentioned & I can't follow the example on your fix.

Tami

chrism2671’s picture

I'm also experiencing this issue. I'm a little more experienced, so I have done the files/ctools/css 777 already (and a few variations) with little avail.

Is it possible to get the dev trunk modified so that it outputs a more useful error message?

Running D6.11

merlinofchaos’s picture

I'm not sure what to put for a message When it fails, I can't necessarily tell why it failed, only that it couldn't create the directory it needs. There's something odd going on here, honestly, because Drupal doesn't let you install without configuring the files directory more or less properly anymore, so I'm surprised so many people run into this issue.

rgraves’s picture

I received the error in the status report and did chmod 777 of my files directory. The error went away and there is now a ctools directory within my /files/ directory.

However, I usually have the files directory not writable by the web server (644) and have subdirectories within it which are writable. This is to force our publishers to organize their files properly rather than putting them all in the root files directory.

Will this setup cause a problem with ctools?

merlinofchaos’s picture

Once the ctools/css directory is created, as long as *that* directory is writable by the webserver everything will be great.

rgraves’s picture

That's what I thought. Thanks.

rgraves’s picture

I just tried changing the permissions on /files/ now that the ctools subdirectory was created and writable. Unfortunately, I get the following error unless my /files/ directory is chmod 777:

Unable to create CTools CSS cache directory. Check the permissions on your files directory.

I'd prefer not to have /files/ writable since staff won't put their files in the proper subdirectories otherwise.

chrism2671’s picture

Curiously this didn't work on my local laptop xampp LAMP/ubuntu setup, but on the live debian set up it worked just fine.

Mysterious.

nickl’s picture

Attached are comparisons to the errors reported by filesystem.
Ctools is already way more verbose than the filesystem example.
The only improvement I would consider is to add the path to the message as per other modules with the same grievances. The before and after images are added as well as the success message displayed in status when all is well.

Patch rolled against HEAD.

nickl’s picture

Version: 6.x-1.0-beta2 » 6.x-1.x-dev
Status: Active » Needs review
andypost’s picture

Another opinion, regulary I get this kind of errors (subfolders) if umask setup incorectly

please, dont forget about #452704: Prevent blocking by firewalls compressed js and css files

nickl’s picture

This is purely a file_check_directory failed issue, afaik.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed nickl's patch with a small typo correction as well. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

SWeddig’s picture

Hi!

I get the following error if I try to apply you patch:

patching file ctools.install
Hunk #1 FAILED at 28.
1 out of 1 hunk FAILED -- saving rejects to file ctools.install.rej

What's wrong?

Thanks, Sandra

merlinofchaos’s picture

I committed this patch all the way back in June; unless you have a version of ctools that dates back to then, this patch won't apply and is probably already applied to what yo uhave.

nomis’s picture

Hi, I had the same problem and i solved it like that :

Go on : Site Configuration / Files System
the path is (in my case) only :
"files"
so click the default button and the path is now :
"sites/default/files"
and dont forget to save the configuration.

I hope it will help someone else ;)

John_Buehrer’s picture

I had the same problem, after upgrading Drupal to 6.17 and restoring my sites/... directory. Fiddling with permissions didn't help. Then I deleted the ctools/css directory hierarchy under default/files, and refreshed the status report screen. Problem fixed!

Apparently the creation really has to occur. Is there no check to see if the directory hierarchy already exists? And deleting only the css directory didn't work, it had to be ctools/css.

(Or maybe I did something wrong in the upgrade step?)

phunster’s picture

6.17 same problem, following comment #20 (Thanks John) worked for me.

fkildoo’s picture

comment #20 fixed my problem as well!

kuan’s picture

#19 works.

itserich’s picture

Relatively new to Drupal.

Moving from shared host to vps.

Got the error message message:

* Unable to create CTools CSS cache directory. Check the permissions on your files directory.
* Unable to create CTools CSS cache directory. Check the permissions on your files directory.

Checked File System #19 which appeared to be as directed "sites/default/files"

Made a backup then deleted "sites/default/files/ctools"

Flushed cache and got this:

# The directory sites/default/files/ctools has been created.
# The directory sites/default/files/ctools/css has been created.

Point is #20 above worked for me. Thanks!

itserich’s picture

I got this error a second time.

I had switched to vps and had permission errors, most of which were fixed.

The host suggested switching to suPHP and this problem came back.

However, this time #20 did not work. I could not delete files/ctools - the system would not let me.

Solution

I renamed the original ctools file ctools1. Created a new ctools and ctools/css and ctools/style and gave them all permissions 777.

It works now. Still can not delete the original ctools1. Don't like using 777 but it seems correct and common.

acbramley’s picture

Comment #20 worked for me too. Cheers!

pkcho’s picture

Version: 6.x-1.x-dev » 6.x-1.8

I am having a similar problem... I receive this error:

"Unable to create CTools CSS cache directory. Check the permissions on your files directory."

But in my case, nothing is created in my default/files directory, so I can't apply the solution mentioned in #20. The permissions are fine on both the default and files directory, so I don't know what's going on.

I just moved my site from a shared host to a VPS. Just recently, I migrated it to a shared host and the ctools cache folders were created fine.

Any clues?

Thank you.
Joe

itserich’s picture

@ signal

Are you sure the permissions are fine? When I changed to a VPS it had a different PHP method which required different permissions.

elgarrai’s picture

I have the same problem when i upload to my server i have this err massage
The CTools CSS cache directory, sites/default/files/ctools/css could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.
I'm using drupal 6.20 with ctools version = "6.x-1.8" info file information ; $Id: ctools.info,v 1.3 2009/07/12 18:11:58 merlinofchaos Exp $

matthew.moses’s picture

#20 worked for me. Make sure you delete the ctools/css/ folder which is in the sites/default/files and not within the modules folder.

brycesenz’s picture

subscribing.

marquito’s picture

Version: 6.x-1.8 » 7.x-1.0-rc1

#20 worked for me too. remember to clear the entire "ctools" directory from sites/default/files

ahmedhanyfawzy’s picture

Title: directory ctools/css creation fails » The CTools CSS cache directory, ctools/css could not be created due to a misconfigured files directory

Worked for me too i put the detailed steps to solve this issue in this blog post
Thanks

ytsurk’s picture

#20's fine .. ;)

merlinofchaos’s picture

It *is* checking.

It's entirely possible that something like SELinux might be making the directory invisible to CTools or something goofy like that, which would explain why deleting it or renaming it and letting CTools create a new one works.

whaigle’s picture

The following change was made and the result was "CTools CSS Cache Exists."
In the file ctools.install, I have changed the following code on line 15 as follows:
function ctools_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
$path = file_create_path('ctools/css');
This last line has been changed to $path = file_createpath('css');
Realize that the 'ctools' has been removed. In my opinion to have the 'ctools/css' is the wrong path since the css directory
is outside of the ctools directory, and the ctools.install needs to create the css folder which is inside the ctools directory. I have no error even after cron is reactivated. Do you think that I should have problems in the future by removing the "ctools/"?

merlinofchaos’s picture

Yes, the path of the directory is [yourfilepath]/ctools/css

Removing the 'ctools' tries to create the wrong directory. There is another 'css' directory in files, but that is not the one ctools uses, that's for core.

jessicakoh’s picture

#20 works.

Thank you @John_Buehrer

ret5’s picture

#20 - FTW!

arcki’s picture

1) Went to drupal_install_folder/sites/default/files
2) moved the folder drupal_install_folder/sites/default/files/ctools/css to drupal_install_folder/sites/default/files/ctools/cssold
3) Created a new drupal_install_folder/sites/default/files/ctools/css
4) made sure it is writable : chmod 777 ctools/css

ergophobe’s picture

As one other possibility - I got this because I had exceeded my disk allocation.

I use Web Enabled for staging new projects and by default a new project only gets a fairly small amount of disk space. So of course it couldn't create add files to the cache -- it couldn't add files to anything!

msociety’s picture

Status: Closed (fixed) » Active

I upgraded to drupal core 7.10 and now I can't get rid of this problem... have tried *all* suggestions.
Even removed and re-installed ctools completely. Running drupal on standard LAMP stack.

Any other suggestions?

thisDrupal’s picture

For what it may help my fellow OSX users around. I hit this snag when trying to copy a working install to a test site location (core Drupal v7.8, on Lion here).
In my case, the problem seemed to be with the _www owner of the ../sites/default/files/ directory and its contents. When copying via the Finder or using Terminal to do a regular cp -pR from source/ to test_site OSX refuses to assign _www as the owner. So I had to force it by doing sudo cp -pR source/ test_site/
Hope it helps.

lcgrs’s picture

Solution #20 has indeed solved this problem.

ytsurk’s picture

again - after server movement - #20 helped.

deleting the ctools dir creats the whole structre again ;)

josejayesh’s picture

i got this error and given a recursive write permission to /sites/default/files folder and fixed the issue

videofog@jayesh-VPCEA43EG /var/www/sites/default $ chmod -R o+w files/
videofog@jayesh-VPCEA43EG /var/www/sites/default $ pwd
/var/www/sites/default
videofog@jayesh-VPCEA43EG /var/www/sites/default $

progone’s picture

make sure the owner of that directory is NOT 'root'

beakalteshome’s picture

I encountered the same problem that ctool was not able to create ctools/css because of the mis-configured file permission. In my drupal 7 site settings.
1. config-->file share-->was configured independently such that I have public, private separate files
2. I looked at my ctools.install file and it says public://ctools
3. changed the file permission for ctool folder under my public directory (files/public/ctools) which I had already custom created to chmod 775 for both the css and the ctools folder
4. problem gone

The difficulty in my case was that there was another ctools folder inside files/ and I was wasting my time trying to change the permission for that.
Make sure you work with the actual ctools folder

merlinofchaos’s picture

Removing tags that shouldn't have been added.

talas’s picture

First, create directory sites/default/files/ctools/css
Second, chmod the directory "css" to 777
All done.

dianacastillo’s picture

# 20 worked for me and then I had to change the file permisions in files and everything was okay again

dddave’s picture

Category: bug » support
Status: Active » Fixed

Old issue with lots of helpful info. Setting to fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

CTools CSS Cache Unable to create
The CTools CSS cache directory, ctools/css could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.

followed this and warning has gone and ctools recreated itself

chlee’s picture

#20 worked for me too. Me happy :-)

Anonymous’s picture

#20 worked for me. Thanks John!

jim.applebee’s picture

#20 Worked for me as well.

Thank you.

cfox612’s picture

Removing the folder all together did not work for me. Once I changed the permissions on BOTH the ctools and css folders the error has stopped (for at least the past 16 hours).


The reappears. I'm not sure what is happening to make it reappear, but it does. As long as I clear the cache it goes away, but seeing as I need to do that at least once a day there has to be a better solution.
couturier’s picture

Go to the next folder higher up and change permissions there.

cfox612’s picture

That folder is set just fine as well.


The error just popped up again for me. Something changed the css folders permissions from 777 to 775. That seems to throw the error. I have no idea what is altering folder permissions since it happened over the weekend it would be difficult to pin point. I do know that no additional posts were added.

couturier’s picture

Drupal automatically corrects folder permissions, I believe. As long as the css folder has been created and permissions remain at 775, that is fine. What is your error? Please copy the wording for us.

cfox612’s picture

Error: The CTools CSS cache directory, ctools/css could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.

The public file system path is: sites/default/files/images
Files and Images are set to 777. There are then individual folders within images for the various content types to keep things more organized, so changing the folder structure is not an option.

If I clear the cache the error goes away, but obviously this isn't the best solution.

couturier’s picture

@cfox612 You are using Drupal 7? Earlier comments in this thread apply to Drupal 6. Try these things for Drupal 7, CTools 7.x-1.3:

1. Check to make sure the most recent version of CTools is installed.
2. Go to sites/default/files/ctools -- If you do not see a "ctools" folder here, something is wrong. Manually create a "ctools" folder.
3. Now, you can manually create a css folder under ctools, like this: sites/default/files/ctools/css -- Make sure the files, ctools and css folder permissions are 775.
4. Your error should disappear. Drupal will automatically correct folder permissions back to 775 if you have them set to anything else, such as 777.

Let us know how it goes.

cfox612’s picture

I removed the ctools folder from /sites/default/files/images, placed new one in /sites/default/files and error has gone away. Hopefully for good!

Thanks!

criscom’s picture

#49 solved it for me. I had custom configured my file system default/files/public and didn't adjust permissions for ctools/css in this directory. Instead I fiddled around default/files/ctools/css, of course, to no avail. After changing the permissions in system default/files/public/ctools/css the error was resolved.

cfox612’s picture

Well that worked about as long as the others. The ctools and css folders I created in /sites/default/files still exists with proper permissions, but the one I deleted within the /sites/default/files/images folder has re-created itself.

Error: The CTools CSS cache directory, ctools/css could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.

My public file system path is "non-standard" (/sites/default/files/images) so I'm wondering if that might have something to do with it?

viswanathsai’s picture

#20 worked for me ...... i deleted sites/files/ctools and problem got resolved.

leistiko_texvet’s picture

FWIW: #51 worked for me.

brodhagen’s picture

Issue summary: View changes

sudo chown -R www-data:www-data /sites/default/files

Had the same error after my site migration, perms were correct but the file owners were wrong. I had to assign the directory (files) and everything inside (-R) to my new 'user:user-group' that had apache web write permissions (a+w); in my case, www-data.

NOTE: can also solve write perm issues with Drupal File System.

surendra77c’s picture

Please configure your file setting :
admin/config/media/file-system follow this link

under : Public file system path
give the path : sites/default/files

remaining keep default as it is . it will work

BassPlaya’s picture

both #20 and #49 worked.
Cheers!

jary’s picture

just make the files writable
chmod o+w sites/default/files

and then it will create ctools directory inside the files folder, make sure to make the ctools and ctools/css folder writable as well

hosttor’s picture

SOLVED change the permission on example.com/web/sites/default/files/ctools to 755

saimonn007’s picture

in my case the problems was in server - I used all space I had, so drupal couldn't make any action.

AlexAndrei04’s picture

El comentario #51 funciono para mi problema. Saludos.

cabita’s picture

#24 worked for me. Thanks.

Powergird’s picture

I just solved this issue and I did like these:

chage these folder from 755 to 777

sites/default/files
sites/default/files/ctools/css
sites/default/files/tmp
sites/default/files/js

I hope it is helpful.

drupalfan2’s picture

I have the same problem.

Till now none of the solutions above worked for me, still unsolved.