On Mac OS Big Sur (11.6.3) with nvi
1.81.6 and several tmux
panels, I accidentally quit Terminal.
Now opening files leads to the message
<file> already locked, session is read-only
<file> unmodified, readonly: line 1
After consulting this answer about recovery files, I was a little confused about the files in /var/tmp/vi.recover/ directory.
The recover.XXXXX files appear to be plaintext emails starting with two special headers,
X-vi-recover-file
andX-vi-recover-path
The second header value points to a path like /var/tmp/vi.recover/vi.YYYYY, which can be either a file or directory.
When it is a file, it is binary. When it is a directory, it is empty.
After creating a copy of the recover.XXXXX file, and seeing it was pointing to "correct" paths already, it was not clear what to update the values to. Using nvi -r <file>
just outputs
No files named <file>, readable by you, to recover.
Anyway, I removed all the recover.* files and vi.*/ folders, and nvi
still opens the file read-only.
Is there a permanent solution, where I do not have to use :set noro
each time I edit the file?
:set nolock
?set nolock
to the nvi startup file ~/.nexrc, the read-only issue is resolved. However, a nice "feature" of the read-only warning is knowing the file is opened already (in another tmux panel or new Terminal tab). The question originally did not mention this, so I'll update to provide more context.lsof
)lsof <file>
does show one entry, and it is fornvi
. I have no visible editing sessions for the file; maybe this is running in thetmux
session from before I quit Terminal? I can check for that. In the meantime, should I make the workarounds above separate Answers?tmux kill-session -a
post as the Answer in a bit, unless otherwise suggested. Thank-you again @D.BenKnoble.