File lost after opening with Ranger & writing with Vim
When I use Ranger to open a file in Vim I cannot save the file afterwards:
"build.hjson" E212: Can't open file for writing WARNING: Original file may be lost or damaged don't quit the editor until the file is successfully written!
As this does not happen on macOS/Linux I guess that WSL keeps a file handle open somewhere.
Steps:
- Install Ranger and Vim
- open Ranger
- go to a Windows directory (/mnt/c/...)
- open a text file (Ranger opens the file in Vim)
- save the file in Vim (:w)
- see the error above
- after exiting Vim/Ranger the file is gone
When I save the file with a different name I can rename it back to its original name in ranger.
If I open the file directly in Vim I can save it again without problems.
Build 15007
Still failing in 15019
I tried to repro with both editors below, but was able to save the file successfully. The file was located on my Windows desktop. Do you have any other programs open inside WSL during your test?
3. /usr/bin/vim.basic
4. /usr/bin/vim.tiny
No, nothing else but ranger and vim are running.
I just tested it again with vim on 15025 and got the same error. It only occurs on a mounted drive though, not in the home directory.
Vim:
sudo apt-get install vim- says Unpacking vim (2:8.0.0311-0york1~16.04)
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Feb 05 2017 20:17:49) Included patches: 1-311
Ranger:
git clone https://github.com/ranger/ranger(commit 912e26b49cb6f7ab29a0becc9887c8a934f6f780)- run
ranger/ranger.py
os-release:
NAME="Ubuntu" VERSION="16.04.1 LTS (Xenial Xerus)"
@JasonLinMS Can I do something to help you guys locate the issue? The bug is still happening in 15063.
strace with ranger & vim:
[pid 1267] rename("test.txt", "/tmp/test.txs~") = -1 EXDEV (Invalid cross-device link)
[pid 1267] stat("test.txt", {st_mode=S_IFREG|0777, st_size=3, ...}) = 0
[pid 1267] getxattr("test.txt", "system.posix_acl_access", 0x7fffce405190, 132) = -1 ENODATA (No data available)
[pid 1267] stat("test.txt", {st_mode=S_IFREG|0777, st_size=3, ...}) = 0
[pid 1267] open("test.txt", O_RDONLY) = 3
[pid 1267] open("/tmp/test.txs~", O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW, 0100777) = 6
[pid 1267] read(3, "OK\n", 8192) = 3
[pid 1267] write(6, "OK\n", 3) = 3
[pid 1267] read(3, "", 8192) = 0
[pid 1267] close(3) = 0
[pid 1267] close(6) = 0
[pid 1267] setxattr("/tmp/test.txs~", "system.posix_acl_access", "\2\0\0\0\1\0\7\0\377\377\377\377\4\0\7\0\377\377\377\377 \0\7\0\377\377\377\377", 28, 0) = -1 EOPNOTSUPP (Operation not supported)
[pid 1267] unlink("test.txt") = 0
[pid 1267] lseek(5, 4096, SEEK_SET) = 4096
[pid 1267] write(5, "tp\1\0\177\0\0\0\2\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0"..., 4096) = 4096
[pid 1267] lseek(5, 8192, SEEK_SET) = 8192
[pid 1267] write(5, "ad\0\0\335\17\0\0\375\17\0\0\0\20\0\0\1\0\0\0\0\0\0\0\375\17\0\0\374\17\0\0"..., 4096) = 4096
[pid 1267] select(1, [0], [], [0], {0, 0}) = 0 (Timeout)
[pid 1267] fsync(5) = 0
[pid 1267] open("test.txt", O_WRONLY|O_CREAT|O_TRUNC, 0777) = -1 ENOENT (No such file or directory)
strace with vim only:
rename("test.txt", "/tmp/test.txr~") = -1 EXDEV (Invalid cross-device link)
stat("test.txt", {st_mode=S_IFREG|0777, st_size=3, ...}) = 0
getxattr("test.txt", "system.posix_acl_access", 0x7fffc15f6e10, 132) = -1 ENODATA (No data available)
stat("test.txt", {st_mode=S_IFREG|0777, st_size=3, ...}) = 0
open("test.txt", O_RDONLY) = 3
open("/tmp/test.txr~", O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW, 0100777) = 5
read(3, "OK\n", 8192) = 3
write(5, "OK\n", 3) = 3
read(3, "", 8192) = 0
close(3) = 0
close(5) = 0
setxattr("/tmp/test.txr~", "system.posix_acl_access", "\2\0\0\0\1\0\7\0\377\377\377\377\4\0\7\0\377\377\377\377 \0\7\0\377\377\377\377", 28, 0) = -1 EOPNOTSUPP (Operation not supported)
unlink("test.txt") = 0
fsync(4) = 0
open("test.txt", O_WRONLY|O_CREAT|O_TRUNC, 0777) = 3
write(3, "OK\n", 3) = 3
fsync(3) = 0
stat("test.txt", {st_mode=S_IFREG|0777, st_size=3, ...}) = 0
stat("test.txt", {st_mode=S_IFREG|0777, st_size=3, ...}) = 0
close(3) = 0
@JasonLinMS Not sure if you read through all of his posts, but it seems like this is happening in only in DrvFS and not necessarily LxFS
Duplicate of #966. We're working on fixing this problem.