nvbn / django-bower

Easy way to use bower with your django project
https://django-bower.readthedocs.io/
518 stars 75 forks source link

Very obscure error when 'bower_components' directory isn't present #48

Closed trey0 closed 9 years ago

trey0 commented 9 years ago

Context: This issue comes up when I run 'manage.py collectstatic' with djangobower installed, but 'manage.py bower' either hasn't been run yet or failed to run properly.

Expected behavior: Either collectstatic should complete without error (obviously, without installing bower files), or an intelligible error should occur within djangobower code such that the problem is easy to trace.

Observed behavior: I get an obscure error from deep within staticfiles, like this:

OSError: [Errno 2] No such file or directory: '/home/vagrant/gds/xgds_plrp/components'

Notice the error is not about the 'bower_components' directory, but about the 'components' directory. As a bower newbie, I had no idea that this directory had anything to do with bower. It's never created when things run properly. I had no easy way to track down what was causing the error.

Turns out, it's due to some historical fallback logic in finders.py that sets the staticfiles path to 'components' if 'bower_components' isn't found. The fallback seems like a fine idea, but if you're already taking the time to check for existence of 'bower_components', maybe you could put in the same check for 'components' and raise an exception if it's not there? (Or something like that, there are many ways to handle it.)

Thanks for producing this extremely useful library!