utils: fix broken symlink copy exception #3785
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First of all: Thanks for your project and awesome work behind MkDocs!
Issue
The pull request fixes an exception with broken symlinks. Broken symlinks were mentioned multiple times in the past in various places. I run into the same with a broken symlink in a recent project with the most recent release.
Expected behavior
Site is built/served without the broken symlink but a warning is provided to the user (also useful for CI/CD checks etc.).
Solution
Based on #668 I added the required check in the utils -> copy_file function to report an warning if a symlink is broken and its file was not found, but continue with the copy and serving/building of the site instead of an exception.
After the fix, it looks like this
How to reproduce
ln -s ../not-existing mylink
Exception
Refs: #1753 #639
I read https://www.mkdocs.org/about/contributing/ but was unsure if I should open the PR against master or another branch. We could make that clear in the contributing guidelines.