Skip to content

BUG - Dangling symlink crashes build #4048

Description

@ed2050

Ran mkdocs serve with a page that links to a jpg file. Just a normal link like this:

[ View result ](/media/cert.line-54.jpg)

the file /media/cert.line-54.jpg is a symlink. Page worked fine before. Then I moved the original file and forgot to update symlink. That left /media/cert.line-54.jpg as a dangling link.

Result - mkdocs crashes hard. Traceback below. I have strict: false in my config root.

Obviously a web server should never crash for a missing file. Config file maybe, missing server plugin, but not a missing document or media.

Error trace

Traceback (most recent call last):
  File "/home/ed2050/Library/Python/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/home/ed2050/Library/Python/lib/python/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/ed2050/Library/Python/lib/python/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/ed2050/Library/Python/lib/python/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ed2050/Library/Python/lib/python/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ed2050/Library/Python/lib/python/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/ed2050/Library/Python/lib/python/site-packages/mkdocs/__main__.py", line 272, in serve_command
    serve.serve(**kwargs)
  File "/home/ed2050/Library/Python/lib/python/site-packages/mkdocs/commands/serve.py", line 85, in serve
    builder(config)
  File "/home/ed2050/Library/Python/lib/python/site-packages/mkdocs/commands/serve.py", line 67, in builder
    build(config, serve_url=None if is_clean else serve_url, dirty=is_dirty)
  File "/home/ed2050/Library/Python/lib/python/site-packages/mkdocs/commands/build.py", line 325, in build
    files.copy_static_files(dirty=dirty, inclusion=inclusion)
  File "/home/ed2050/Library/Python/lib/python/site-packages/mkdocs/structure/files.py", line 122, in copy_static_files
    file.copy_file(dirty)
  File "/home/ed2050/Library/Python/lib/python/site-packages/mkdocs/structure/files.py", line 485, in copy_file
    utils.copy_file(self.abs_src_path, output_path)
  File "/home/ed2050/Library/Python/lib/python/site-packages/mkdocs/utils/__init__.py", line 123, in copy_file
    shutil.copyfile(source_path, output_path)
  File "/usr/local/Cellar/python@/3.8.3/Frameworks/Python.framework/Versions/lib/python/shutil.py", line 261, in copyfile
    with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '/home/ed2050/mkdocs/media/cert.line-54.jpg'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions