Opened 8 years ago

Closed 8 years ago

#22704 closed New feature (wontfix)

"collectstatic" fails when there is a dangling symlink (in the source)

Reported by: Daniel Hahler Owned by: nobody
Component: contrib.staticfiles Version: dev
Severity: Normal Keywords: symlink
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


If there exists a dangling symlink in one of STATICFILES_DIRS, collectstatic aborts as follows:

% python collectstatic --noinput
Copying '/tmp/'
Traceback (most recent call last):
  File "", line 10, in <module>
  File "…/django-master/django/core/management/", line 429, in execute_from_command_line
  File "…/django-master/django/core/management/", line 421, in execute
  File "…/django-master/django/core/management/", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "…/django-master/django/core/management/", line 337, in execute
    output = self.handle(*args, **options)
  File "…/django-master/django/core/management/", line 532, in handle
    return self.handle_noargs(**options)
  File "…/django-master/django/contrib/staticfiles/management/commands/", line 168, in handle_noargs
    collected = self.collect()
  File "…/django-master/django/contrib/staticfiles/management/commands/", line 107, in collect
    handler(path, prefixed_path, storage)
  File "…/django-master/django/contrib/staticfiles/management/commands/", line 314, in copy_file
    with as source_file:
  File "…/django-master/django/core/files/", line 35, in open
    return self._open(name, mode)
  File "…/django-master/django/core/files/", line 173, in _open
    return File(open(self.path(name), mode))
IOError: [Errno 2] No such file or directory: u'/tmp/'

I think there should be at least an option to skip dangling symlinks, or skip them by default and log a warning message.

Change History (4)

comment:1 Changed 8 years ago by Tim Graham

Is this really on master? #20780 seems like a duplicate which says it's fixed.

comment:2 Changed 8 years ago by Daniel Hahler

Yes, I have tested it yesterday on master.

I came across #20780 also, but it seems to be about handling dangling symlinks in the target (STATIC_ROOT), not the source (STATICFILES_DIRS).

comment:3 Changed 8 years ago by Daniel Hahler

Summary: "collectstatic" fails when there is a dangling symlink"collectstatic" fails when there is a dangling symlink (in the source)

comment:4 Changed 8 years ago by Aymeric Augustin

Resolution: wontfix
Status: newclosed

I think that's the correct behavior. "Errors shouldn't pass silently" -- PEP20.

A dangling symlink is an invalid input for the collectstatic process. It indicates a problem. Django cannot know what the proper resolution for this problem is.

If you still disagree, please start a discussion on the django-developers mailing list.

Note: See TracTickets for help on using tickets.
Back to Top