I'm a programmer diagnosing a customer's issue with our software. We're having some problems writing into the user's Documents folder in macOS Mojave 10.14.6.*
It turns out that the customer's ~/Documents folder is a symlink to itself, causing ELOOP errors when calling file APIs, and a Too many levels of symbolic links error when attempting to view its contents in the Terminal with the ls command.
However, in the Finder, the folder displays normally, and appears to contain 15GB of contents.
The first time we saw this issue I wrote it off as an unsolved mystery, but this is the second customer we have seen in the past few years with a Documents folder that is a symbolic link to itself.
So my questions are:
- How is this possible?
- What can cause this configuration? Is there any legitimate reason it might be configured this way?
- Is it safe to tell the user just to move all the contents somewhere safe, delete the folder, and then recreate it in the Finder?
* The path is obtained by passing NSDocumentDirectory into NSSearchPathForDirectoriesInDomain.



find -L $HOME/Documents -type landdiskutil verifyVolume /and send the output of the two commands back to you. (delete comment/edit reason: firstfindcommand was wrong) – klanomath Nov 22 '19 at 15:33Documentssymlink, the customer also has a folder namedDocuments<Space>which contained all their actual files. The difference wasn't visible in the Finder, but dragging it into the Terminal inserted a backslash escape, solving the mystery. Thank you! – Rich Nov 25 '19 at 16:52