Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'CachedFileFinder' object has no attribute 'storages' #293

Closed
honi opened this issue Dec 11, 2013 · 12 comments
Closed

AttributeError: 'CachedFileFinder' object has no attribute 'storages' #293

honi opened this issue Dec 11, 2013 · 12 comments

Comments

@honi
Copy link

honi commented Dec 11, 2013

I'm having the following problem. Not sure if it's a misconfiguration on my end or a bug.

I'm using Bower to install some components. I've added to STATICFILES_DIRS the directory where the components are installed.

Here are some relevant parts from settings.py

STATICFILES_FINDERS = (
    'pipeline.finders.AppDirectoriesFinder',
    'pipeline.finders.FileSystemFinder',
    'pipeline.finders.PipelineFinder',
    'pipeline.finders.CachedFileFinder',
)
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
DEBUG = False

When I run collectstatic, I get the following error:

AttributeError: 'CachedFileFinder' object has no attribute 'storages'

However, If I remove CachedFileFinder, collectstatic works fine.

@cyberdelia
Copy link
Member

Oh, that's a terrible regression. Could you provide the full traceback?
In the meantime, you can use pipeline 1.3.17.

@honi
Copy link
Author

honi commented Dec 11, 2013

Sure! The error happened with django 1.6 and django-pipeline installed from github.

Traceback (most recent call last):
  File "./src/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/.../venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/.../venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/.../venv/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/.../venv/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/.../venv/lib/python2.7/site-packages/django/core/management/base.py", line 415, in handle
    return self.handle_noargs(**options)
  File "/.../venv/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 167, in handle_noargs
    collected = self.collect()
  File "/.../venv/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 118, in collect
    for original_path, processed_path, processed in processor:
  File "/.../venv/src/django-pipeline/pipeline/storage.py", line 39, in post_process
    packager.pack_javascripts(package)
  File "/.../venv/src/django-pipeline/pipeline/packager.py", line 110, in pack_javascripts
    return self.pack(package, self.compressor.compress_js, js_compressed, templates=package.templates, **kwargs)
  File "/.../venv/src/django-pipeline/pipeline/packager.py", line 104, in pack
    content = compress(paths, **kwargs)
  File "/.../venv/src/django-pipeline/pipeline/compressors/__init__.py", line 55, in compress_js
    js = self.concatenate(paths)
  File "/.../venv/src/django-pipeline/pipeline/compressors/__init__.py", line 141, in concatenate
    return "\n".join([self.read_text(path) for path in paths])
  File "/.../venv/src/django-pipeline/pipeline/compressors/__init__.py", line 212, in read_text
    content = self.read_bytes(path)
  File "/.../venv/src/django-pipeline/pipeline/compressors/__init__.py", line 206, in read_bytes
    file = default_storage.open(path)
  File "/.../venv/lib/python2.7/site-packages/django/core/files/storage.py", line 33, in open
    return self._open(name, mode)
  File "/.../venv/src/django-pipeline/pipeline/storage.py", line 149, in _open
    name, storage = self.find_storage(name)
  File "/.../venv/src/django-pipeline/pipeline/storage.py", line 142, in find_storage
    for storage in finder.storages.values():
AttributeError: 'CachedFileFinder' object has no attribute 'storages'

@kevin-brown
Copy link

I just ran into this issue after I moved CachedFileFinder up and django.contrib.staticfiles.finders.AppDirectoriesFinder to the bottom.

storage.py#L142 depends on storages being present on the finder, but this is only present in FileSystemFinder and anything that subclasses it.

After I reverted that commit, the exception went away.

@liquidpele
Copy link

This is still an issue with 1.3.23, also in glob.py's glob1 function, you catch all exceptions and return an empty list thus ignoring errors... that's pretty much horrible practice in general, beyond that silently not grabbing expected files due to an exception is just all kinds of terrible just by itself. /rant

For those curious, pip install django-pipeline==1.3.17 to get a working copy

@rosscdh
Copy link

rosscdh commented Jun 30, 2014

+1 Happens in django-pipeline==1.3.24 when referring to a .less file in PIPELINE_CSS

@santagada
Copy link

So this is still a issue?

@rosscdh
Copy link

rosscdh commented Jul 1, 2014

@santagada appears so I'm afraid

@rosscdh
Copy link

rosscdh commented Jul 1, 2014

This works: but if i uncomment then it fails with above message

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'pipeline.finders.FileSystemFinder',
    'pipeline.finders.AppDirectoriesFinder',
    'pipeline.finders.PipelineFinder',
    #'pipeline.finders.CachedFileFinder',  # Causes issue with .less files https://github.com/cyberdelia/django-pipeline/issues/293
)

@santagada
Copy link

What was happening to me was that I had a wrong filename on one of the dependencies... correcting it the problem was solved.

@rosscdh
Copy link

rosscdh commented Jul 2, 2014

@santagada I think thats the problem indeed. I reference .less files in PIPLINE_CSS and are using the less converter as per docs... ie

PIPELINE_CSS = {
  'core': {
        'source_filenames': (
            'less/introjs-custom.less'
....

PIPELINE_COMPILERS = [
    'pipeline.compilers.less.LessCompiler',
    'react.utils.pipeline.JSXCompiler',
]

@rizumu
Copy link

rizumu commented Jul 8, 2014

I just hit this to and it turned out I had a ".min" as part if a source_filename but the file on disk wasn't ".min". Simple oversight, but the error message is misleading for when a file can't be found, it should better error with the name of the file that can't be found.

@santagada
Copy link

I agree, this ticket should be renamed for "better error message on file not found"

muminoff pushed a commit to muminoff/oh-my-wallet that referenced this issue Aug 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants