#29980: SuspiciousFileOperation when running collectstatic -------------------------------------+------------------------------------- Reporter: Henrik Sejersen | Owner: nobody Type: Bug | Status: closed Component: contrib.staticfiles | Version: 2.1 Severity: Normal | Resolution: wontfix Keywords: | Triage Stage: | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by Tim Graham):
* status: new => closed * resolution: => wontfix Old description: > 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 exception is raised when using Django 2.0.9 > and also when using Django 2.1.3. > > 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? 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\) New description: 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 exception is raised when using Django 2.0.9 and also when using Django 2.1.3. 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? 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\) }}} -- Comment: I believe it's [https://bugs.python.org/issue31047 a regression in Python 3.6.7 and 3.7.1] which should be fixed in the next releases. -- Ticket URL: <https://code.djangoproject.com/ticket/29980#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/062.df2bf86e66d64e0c6dedd2f5ea84c0ed%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.