wakatime-mode
wakatime-mode copied to clipboard
Getting error `Invalid coding system: auto-save-coding` when running `recover-this-file` on certain files
Sometimes when I try to run recover-this-file
I get an error Invalid coding system: auto-save-coding
which prevents the file from being recovered. I had to manually find the autosave file and copy contents. After some debugging efforts, I discovered that if I disable wakatime then this wouldn't happen on the same file, when I switch it on again it happens again, so I currently think this is a bug of wakatime. Strangely it doesn't happen to all of my recover-this-file
attempts and I'm not sure what's different in the problematic files from the rest.
I'm using Emacs 24.5 on OS X Yosemite, with Spacemacs
Same here.
Same also, Ubuntu w/ Emacs 24.5.3 and wakatime 1.0.2
Same here, Gentoo, Emacs 25.2.1
So the issue appears to be in how wakatime calls out to the shell from an auto-save buffer during restore. However, there's no reason to log time spent in those buffers, so just excluding from consideration seems to resolve the issue e.g.:
;; override package functions to avoid auto-save buffers and auto-save-coding issue
(defun wakatime-ping ()
"Send ping notice to WakaTime."
(when (and
(buffer-file-name (current-buffer))
(not (auto-save-file-name-p (buffer-file-name (current-buffer)))))
(wakatime-call nil)))
(defun wakatime-save ()
"Send save notice to WakaTime."
(when (and
(buffer-file-name (current-buffer))
(not (auto-save-file-name-p (buffer-file-name (current-buffer)))))
(wakatime-call t)))
I'll put in a PR when I have time.
Added the change with 2531cb58287770883ba534d20b3288955c4d6ef3.
I just ran into this. Wakatime version 1.0.2 so I'm not sure if I have the latest commit. Installed through Melpa.
I ran into this just now. The commit mentioned above is included in my wakatime-mode.el
, so maybe something else is also needed to fix this. Disabling global-wakatime-mode
makes it work.
Yea, it must be related to something else. Maybe a race condition and the above commit just reduces the chances of it triggering?
Running into this issue as well.
'auto-save-coding is a pseudo-coding-system used in (recover-file FILE). This error occurs when attempting to evaluate it as a coding-system outside of the recover-file function. This occurs in wakatime-mode wakatime-call. I think this patch will fix it.
--- a/wakatime-mode.el
+++ b/wakatime-mode.el
@@ -159,6 +159,9 @@ the wakatime subprocess occurs."
(let*
(
(command (wakatime-client-command savep))
+ (coding-system-for-read
+ (unless (eq coding-system-for-read 'auto-save-coding)
+ coding-system-for-read))
(process
(start-process
"Shell"
@h2oota Have you submitted a pull request yet? I have not tested it yet, because it would dirty wakatime-mode's source tree in my package management system.
Added the patch with aa04a5551e782992ddaea890d8547863b0d6ba60.
Thanks @alanhamlett!
Thanks @alanhamlett!. It works perfectory.
BTW, I don't think https://github.com/wakatime/wakatime-mode/commit/2531cb58287770883ba534d20b3288955c4d6ef3 is necessary. It should be reverted. The only situation where the conditional expression for this modification would hold is if you opened the autosave file directly, in which case the action that we opened the autosave file should be recorded.
BTW, I don't think 2531cb5 is necessary. It should be reverted. The only situation where the conditional expression for this modification would hold is if you opened the autosave file directly, in which case the action that we opened the autosave file should be recorded.
Thanks, reverted it with 25fb775178d16decb818b75f32fd23301c0f5da0.