django-pipeline icon indicating copy to clipboard operation
django-pipeline copied to clipboard

Empty output with pipeline.finders

Open bitcity opened this issue 10 years ago • 12 comments

The setting below generates empty JS/CSS files in STATIC_ROOT

STATICFILES_FINDERS = ( 
    'pipeline.finders.FileSystemFinder',
    'pipeline.finders.AppDirectoriesFinder',
    'pipeline.finders.CachedFileFinder',
    'pipeline.finders.PipelineFinder',
)

The ones below work, but they also copy the source JS/CSS when I run collectstatic, which has to be manually removed. Is it a settings issue in my setup or is it a bug in django-pipeline?

STATICFILES_FINDERS = ( 
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'pipeline.finders.PipelineFinder',
)

bitcity avatar Feb 09 '15 09:02 bitcity

I had the same problem, but I found this thread after some debugging and I found reason for that behaviour.

pipeline's finders are doing a good job but only when collectstatic is used. During which all files are ignored (not copied to STATIC_ROOT) and only files from compression process are saved there (to STATIC_ROOT). By this it works perfect no crap in static root only results of compression process. But...

In debug mode files are not compressed, but should be copied as they are to static root (compilation of less/sass is made later on those copied files). But because of the ignored list from finder classes, static files are not copied to static root for further usage, so FileSystemFinder can not find them.

This is the course of problems: https://github.com/cyberdelia/django-pipeline/blob/master/pipeline/finders.py#L69-L117 https://github.com/cyberdelia/django-pipeline/blob/master/pipeline/glob.py#L29

Because of the above this for is never entered, and paths variable is never filled. The path variable is essential for ruther procedures to render script tags. https://github.com/cyberdelia/django-pipeline/blob/master/pipeline/packager.py#L26-L28

So basicly I see two options

  1. Somehow use pipeline's finder only for collectstatic purpose.
  2. Exclude files from pipeline configuration to be ignored (but this will also copy them while using collectstatic and they will be useless because on production compressed files are used).

Unfortunately I don't have time right now for further digging or creating fixing pull request ;/, but I think my observations will help.

I am also thinking about inappropriate setting configuration as @addremove suggest, because file finders are able to find those files in static dir inside my apps, so I am not sure if we should blame django for that.

akszydelko avatar Feb 28 '15 17:02 akszydelko

Right in time after I wrote previous comment it hit me... The workaround solution is very simple.

On production use this:

STATICFILES_FINDERS = ( 
    'pipeline.finders.FileSystemFinder',
    'pipeline.finders.AppDirectoriesFinder',
    'pipeline.finders.CachedFileFinder',
    'pipeline.finders.PipelineFinder',
)

But for local development this:

STATICFILES_FINDERS = ( 
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'pipeline.finders.PipelineFinder',
)

But of course it would be nice to have it defined only once.

akszydelko avatar Feb 28 '15 17:02 akszydelko

Probably related https://github.com/cyberdelia/django-pipeline/issues/398 & https://github.com/cyberdelia/django-pipeline/issues/378

bitcity avatar May 24 '15 14:05 bitcity

Debugging further, I found 1.3.7 works correctly (with STATICFILES_FINDERS set to pipeline.finders.*). All the versions after that generate empty output files.

bitcity avatar May 26 '15 08:05 bitcity

So I changed the finders to the following in my development environment:

STATICFILES_FINDERS = ( 
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'pipeline.finders.PipelineFinder',
)

But because I manage front-end packages with Bower then I get a lot of directories and files in my static tree (for example, the src directory for Bootstrap is copied in the Django project STATIC_URL but not removed after compression tasks).

Please see https://github.com/cyberdelia/django-pipeline/issues/482 for more information about polluted STATIC_URL directory and slow page load.

If someone could answer to give advice or review the ticket that would be great. It seems there are only two of us having this problem or at least speaking about it.

qcaron avatar Jul 29 '15 07:07 qcaron

I have the same problem.... pipeline.finders.* generates empty files while django.contrib.staticfiles.finders.* do generate files correctly but also copies every file in the static dir.

sam-dieck avatar Sep 18 '15 05:09 sam-dieck

@samdieck look att #499 it broke things for me

SverkerSbrg avatar Sep 18 '15 07:09 SverkerSbrg

I have that problem, too. Trying to wrap my head around the issue and looking for options.

In the meantime, isn't the first bug here that "invalid" paths in source_filenames do not yield an error message? Is there any reason to stay silent about such a critical error?

Then at least noticing this problem and troubleshooting it would already get a lot easier.

hheimbuerger avatar Oct 15 '15 23:10 hheimbuerger

+1

MrCsabaToth avatar Jul 14 '16 16:07 MrCsabaToth

+1

belugame avatar Sep 16 '16 12:09 belugame

+1

mcanaves avatar Oct 28 '16 08:10 mcanaves

+1

tehfink avatar Mar 16 '18 16:03 tehfink