Describe the bug
In Windows, with undofile enabled and undodir set to a local directory, saving a file on a mapped network drive which is not world-readable results in E828: Cannot open undo file for writing: ...
To Reproduce
Detailed steps to reproduce the behavior:
mkdir /tmp/myshare (umask 027 && touch /tmp/myshare/example.txt) echo ' [MyShare] path = /tmp/myshare writeable = yes' >>/etc/samba/smb.conf killall -HUP smbd
net use S: \\computer1\MyShareundofile and local undodir:vim -u NONE -c "set undofile | set undodir=%TEMP%" S:\example.txti1<Esc>:w<CR>i2<Esc>:w<CR>On the second save, E828: Cannot open undo file for writing: C:\Users\User\AppData\Local\Temp\S%%example.txt will be produced.
Expected behavior
Undo would work as expected and no error would be produced.
Environment (please complete the following information):
Additional context
icacls "%TEMP%\S%%example.txt" prints
C:\Users\User\AppData\Local\Temp\S%%example.txt S-1-5-21-189028407-2721759871-347389160-1000:(R,W)
S-1-22-2-1000:(R)
Which indicates that the undo file has permissions for the SID on the share and is not inheriting permissions from the parent directory, which means that the SID for the current user does not have read/write permission on the undo file.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
Issue persists in VIM 9.1 on Windows 11 23H2.
Is there any workaround? This is a consistent annoyance.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
set undodir?
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
The error occurs when undodir is set.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
yes what I meant: so set it to a non network share
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Yes, as I explained in the bug description, the issue occurs when undodir is set to a local directory (%TEMP% in the reproduction steps)
In Windows, with undofile enabled and undodir set to a local directory
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
yes, the issue is with the permissions (different ownership). This is currently not supported. Vim verifies that the undofile is from the same user account.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Vim verifies that the undofile is from the same user account.
Can you elaborate? Are you saying that Vim creates the undofile with the SID of the original file, rather than the current user, then complains that the undofile is not the user SID when it writes it a second time?
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
(This issue did not exist in VIM 8.1)
I own the network-shared file Z:\file.txt (owner is SERVER\me)
I also own the local undo file C:\undodir\Z%%file.txt (owner is WORKSTATION\me)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
This is driving me crazy!
I need to edit files in samba share and undo dir is in my local Windows NTFS. I also edit local files so need undo dir in local drive.
I can edit undo files permissions to be writable, gvim can save the undo file changes once but changes the file permissions, so fails second time. This is weird.
undo file permissions should 1. not be changed once the file exists, 2. inherited from undo folder or gvim user, not from source file permissions.
Whats worse is that the original file in the smb share is editable by gvim!
This is a bug.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Still a bug in 9.2. I now work around this by checking whether expand(':p') is on a network-mapped drive and resetting undodir to a network folder in function called by "au BufEnter * ...". I'm sure there's a better way, but this is working for me. Feels yucky though.
if exists('$HOME') && expand($HOME) =~ '^[FZ]:' && isdirectory(expand($HOME)) let s:udir = expand($HOME . '.vim_undo') endif function! SetUndoDir() if has('persistent_undo') if expand('<afile>:p') =~ '^[F-Z]:' if exists('s:udir') let &undodir = s:udir else set undodir=. endif else let &undodir = s:local_udir endif set undofile endif endfunc au BufEnter * call SetUndoDir()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()