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