macOS Autosave Information Stuck Vim Swap File

I recently ran into a fairly weird issue in macOS. I somehow managed to have a Vim .swp file stuck in:

/Users/jfab/Autosave Information

For the uninitiated, every time you open a file in Vim (or a derivative, like Neovim in this case), it will create another file on the file system that has the same name as the currently open file but with a .swp extension appended to the end. The purpose is to cache whatever changes are being made so that if something bad happens (Vim crashes, your system crashes, etc.) the work that may have been done isn’t completely lost. If a file is gracefully closed, the swap file is automatically removed. If a file isn’t gracefully closed, though, the swap file will linger. When the original file is re-opened, Vim will notify the user about the swap file’s existence and give the user various options such as the ability to recover from the swap file, ignore it, etc.

Somehow, I had a swap file stuck in the path above that was related to my Neovim’s configuration file:

This was annoying because every time I opened my Neovim config I would receive the swap file prompt. This normally wouldn’t be a big issue because I had no idea what was in the file and my config was fine… so at the prompt I decided to delete the swap file. Unfortunately, the file didn’t actually delete, and I received the same prompt regarding the swap file the next time I opened my Neovim config. Opting to recover from the swap file similarly had no impact.

As per the screenshot above, I could see the file on my file system, but attempts to remove it from the CLI, even with sudo, were unsuccessful… which was strange since my account owns the file. On a frustrated whim, since this was something that seemed macOS specific, I was curious if it would play nicer with macOS-specific tools. I ran:

open 'Library/Autosave Information'

Then I was able to use Finder to right-click on the file and delete it. Extremely strange, but with the problem fixed I didn’t feel the need to dig into it any deeper.