Discussion:
Error when running python manage.py collectstatic
Henrik Sejersen
2018-11-20 09:26:53 UTC
Permalink
Hi



I get an error when running python manage.py collectstatic. The error is a
SuspiciousFileOperation exception because “The final path must be the same
as the base path”.

The strange thing is that I only get this error when my python version is
3.7.1. I do not get the error, if I change the standard interpreter version
to 3.6.5 with the exact same dependencies? I am using Django 2.1.3. The
method responsible for the exception appears only to be called when using
python 3.7.1. Here is the stack (I have added print of the local variables
base, base_path, and final_path inside the safe_join method):



(oekonomistyring) P:\python\odk\oekonomistyring>python manage.py
collectstatic

This is base: P:\python\odk\oekonomistyring\collectstatic\

This is base_path: P:\python\odk\oekonomistyring\collectstatic\

This is final_path: P:\python\odk\oekonomistyring\collectstatic\

This is base: P:\python\odk\oekonomistyring\collectstatic\

This is base_path: P:\python\odk\oekonomistyring\collectstatic\

This is final_path: P:\python\odk\oekonomistyring\collectstatic\



You have requested to collect static files at the destination

location as specified in your settings:



P:\python\odk\oekonomistyring\collectstatic\



This will overwrite existing files!

Are you sure you want to do this?



Type 'yes' to continue, or 'no' to cancel: yes

This is base: P:\python\odk\oekonomistyring\static

This is base_path: P:\python\odk\oekonomistyring\static

This is final_path: P:\python\odk\oekonomistyring\static\

This is base: P:\python\odk\oekonomistyring\static

This is base_path: P:\python\odk\oekonomistyring\static

This is final_path: P:\python\odk\oekonomistyring\static\assets

This is base: P:\python\odk\oekonomistyring\static

This is base_path: P:\python\odk\oekonomistyring\static

This is final_path: P:\python\odk\oekonomistyring\static\assets\css

This is base: P:\python\odk\oekonomistyring\collectstatic\

This is base_path: P:\python\odk\oekonomistyring\collectstatic\

This is final_path:
P:\python\odk\oekonomistyring\collectstatic\assets\css\custom_errors.css

Traceback (most recent call last):

File "manage.py", line 15, in <module>

execute_from_command_line(sys.argv)

File
"C:\Users\venv\37\oekonomistyring\lib\site-packages\django\core\management\__init__.py",
line 381, in execute_from_command_line

utility.execute()

File
"C:\Users\venv\37\oekonomistyring\lib\site-packages\django\core\management\__init__.py",
line 375, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)

File
"C:\Users\venv\37\oekonomistyring\lib\site-packages\django\core\management\base.py",
line 316, in run_from_argv

self.execute(*args, **cmd_options)

File
"C:\Users\venv\37\oekonomistyring\lib\site-packages\django\core\management\base.py",
line 353, in execute

output = self.handle(*args, **options)

File
"C:\Users\venv\37\oekonomistyring\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py",
line 188, in handle

collected = self.collect()

File
"C:\Users\venv\37\oekonomistyring\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py",
line 114, in collect

handler(path, prefixed_path, storage)

File
"C:\Users\venv\37\oekonomistyring\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py",
line 343, in copy_file

if not self.delete_file(path, prefixed_path, source_storage):

File
"C:\Users\venv\37\oekonomistyring\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py",
line 249, in delete_file

if self.storage.exists(prefixed_path):

File
"C:\Users\venv\37\oekonomistyring\lib\site-packages\django\core\files\storage.py",
line 308, in exists

return os.path.exists(self.path(name))

File
"C:\Users\venv\37\oekonomistyring\lib\site-packages\django\contrib\staticfiles\storage.py",
line 46, in path

return super().path(name)

File
"C:\Users\venv\37\oekonomistyring\lib\site-packages\django\core\files\storage.py",
line 321, in path

return safe_join(self.location, name)

File
"C:\Users\venv\37\oekonomistyring\lib\site-packages\django\utils\_os.py",
line 55, in safe_join

'component ({})'.format(final_path, base_path))

django.core.exceptions.SuspiciousFileOperation: The joined path
(P:\python\odk\oekonomistyring\collectstatic\assets\css\custom_errors.css)
is located outside of the base path component (P:\python\odk
\oekonomistyring\collectstatic\)
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/79a3713b-e5bd-4dd1-b9fd-1cac47688574%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jason
2018-11-20 14:13:33 UTC
Permalink
I suspect this might be a regression with 3.7. Can you confirm this also
exists with latest django 2.0.x version?

You can also make a bug report at https://code.djangoproject.com/query
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/882829ae-b7a1-4428-85b4-135c497fc7dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Henrik Sejersen
2018-11-23 08:41:19 UTC
Permalink
Hi Jason

Yes, I get the same error with Django 2.0.9 (the latest version) and Python
3.7.1 - I am just about to make a bug report. Thanks!
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ed409140-1c33-4fc7-94db-13176eb26157%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jason
2018-11-24 14:03:24 UTC
Permalink
I suspect this is not an issue with django itself, but rather the python
language runtime on windows

https://bugs.python.org/issue31047#msg328322

It'll be included in the next python patch release, I suspect.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8faa1028-1a4c-4fb1-8f16-8e20b810ce2b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...