Django Collectstatic Suspicious File operation

915 views Asked by At

I am trying to run collectstatic on heroku. When I got this error:

remote: 'component ({})'.format(final_path, base_path)) 
remote: django.core.exceptions.SuspiciousFileOperation: The joined path (/tmp/build_4652acfe079723bc273763513a187201/fonts/glyphicons-halflings-regular.eot) is located outside of the base path component (/tmp/build_4652acfe079723bc273763513a187201/staticfiles) 

I thought perhaps I had missed something with collectstatic on my end, so I ran it locally, and got the exact same error.

Then I went looking. I found:

/home/malikarumi/Projects/aishah/jamf35/staticfiles/bootstrap/fonts/glyphicons-halflings-regular.eot

and

/home/malikarumi/Projects/aishah/jamf35/static/bootstrap/fonts/glyphicons-halflings-regular.eot

My settings:

STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static/bootstrap/fonts/'),

There is a ticket out there, but it seems to be about paths, and I see nothing wrong with my paths, https://code.djangoproject.com/ticket/27201 Another one deals with files, and might be closer to my issue, because it has to do with created tmp files, but I really can't tell: https://code.djangoproject.com/ticket/26644

I should note that I also looked at Django: The joined path is located outside of the base path component, Django: How to allow a Suspicious File Operation / copy a file, and Django | joined path is located outside of the base path component {% static img.thumbnail.url %}, Error 400 with whitenoise, but they seem to be more about MEDIA ROOT issues.

I'm not sure what the fix is, here. Please advise. Thanks.

1

There are 1 answers

1
D. Evans On BEST ANSWER

Your STATICFILES_DIRS setting looks odd. Are you sure you don't want this?

STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'),]

The problem is that one of your CSS files has a relative reference which is resolving outside of the static directory, and I think that's because you have static/bootstrap/fonts where you should just have static.