I am having a strange problem that seams to be caused by VIM, the Linux VFS cache, ecryptfs and/or something file system related:
- I open a file in VIM, modify it and save it.
- I try to access the file.
Expected behaviour
The file should be accessible as soon as :w
reports the file as written.
Actual behaviour
The file does not exist.
If I wait a bit (usually less then a second) the file turns up.
This is especially cumbersome when working with Python code and left over pyc
files. I often ended up starting the old code as the new py
file was not ready, yet. I recently added export PYTHONDONTWRITEBYTECODE=1
to my .bashrc
so I get a meaningful error message rather than executing the old code. It is still very awkward as any auto reloader code (e.g. from Django) fails to reload every 5-10 times because the file I changed goes missing for a short period of time. With the pyc
files in place the auto reloader sometimes ended up loading the old pyc
file and after that never found out that the py
file has been modified and triggered another reload.
System details and configuration
My machine has plenty of RAM (32 GiB), an SSD and is basicly idle. Therefore I do not think that slow I/O is causing this. The file is very small (<1 KiB) and it also happens for empty files. I am using a crypted $HOME
using ecryptfs so this might be part of the problem. I was unable to reproduce this on my /tmp
mount which uses a tmpfs
file system.
VIM settings
The reason why the file is moved away and replaced by a new file is caused by my VIM settings:
set backup
set backupskip=
set backupdir=$HOME/.vimbackup
set writebackup
I would expect the new
file to be accessible right after VIM reports that the file has been written. I checked the VIM documentation for any hints of a delayed write, but did not find anything. I was unable to reproduce this using the shell commands mv
, cp
and rm
so I think VIM is doing something different.
What else could be causing this? How can I solve this.
backupdir
, thus this probably discards issues with the filesystem. It's likely a bug/miss-feature on Vim still present on NeoVim.