I'm experiencing a weird problem with Emacs on Windows where sometimes, after a while, the current buffer I'm in throws an error when attempting to save the file. I can't seem to reliably reproduce the issue (since when I first open the file, it saves fine and even for a few times after that), but after working on it for a while, suddenly I'll get an error when attempting to save the file. The only resolution is to restart Emacs; simply killing and re-opening the buffer has no effect. Turning on toggle-debug-on-error
gives me the following:
Debugger entered--Lisp error: (file-error "Opening output file" "invalid argument" "c:/Users/sonictk/Git/experiments/opengl_test/main.cpp")
write-region(nil nil "c:/Users/sonictk/Git/experiments/opengl_test/main.cpp" nil t "~/Git/experiments/opengl_test/main.cpp")
basic-save-buffer-2()
basic-save-buffer-1()
basic-save-buffer()
save-buffer(1)
call-interactively(save-buffer nil nil)
command-execute(save-buffer)
I'm not sure how to go about debugging this further since these seem to be built-in functions; could anyone provide any advice on how best I should proceed?
I tried turning on debug-on-entry
for write-region
for a file that doesn't seem to have the issue compared with a file that does, and I couldn't see any difference passed to the function calls
``` This works:
write-region(nil nil "c:/Users/sonictk/Git/experiments/opengl_test/shaders/vert.glsl" nil t "~/Git/experiments/opengl_test/shaders/vert.glsl")
Somehow, this doesn't, after a while:
- write-region(nil nil "c:/Users/sonictk/Git/experiments/opengl_test/main.cpp" nil t "~/Git/experiments/opengl_test/main.cpp") ```
I can't understand it; what could be the issue?
UPDATE: As usual, I find the answer only after giving up after a few hours and posting on the interwebs; turns out irony-mode
was keeping an open file handle to the file in question for some reason which prevented anything (not just Emacs) from overwriting the file. Now I just have to figure out why irony is behaving the way it is only with this file in particular.
C-x C-w
with the same name worked for me. I've also had this issue when I've had opened Notepad++ but not the file I was saving in Emacs and closing Notepad++ solved the issue.git diff
open while saving a file with a diff, this happens. from your prompt it looks like you're editing source code in git, so maybe you were diffing it at the time.