wakatime-mode icon indicating copy to clipboard operation
wakatime-mode copied to clipboard

Getting error `Invalid coding system: auto-save-coding` when running `recover-this-file` on certain files

Open x-ji opened this issue 8 years ago • 6 comments

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

x-ji avatar Sep 13 '15 09:09 x-ji

Same here.

incandescentman avatar Nov 11 '15 06:11 incandescentman

Same also, Ubuntu w/ Emacs 24.5.3 and wakatime 1.0.2

ashgillman avatar Jun 24 '16 03:06 ashgillman

Same here, Gentoo, Emacs 25.2.1

lockie avatar Aug 13 '17 15:08 lockie

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.

andrew-christianson avatar Sep 19 '18 21:09 andrew-christianson

Added the change with 2531cb58287770883ba534d20b3288955c4d6ef3.

alanhamlett avatar Sep 20 '18 07:09 alanhamlett

I just ran into this. Wakatime version 1.0.2 so I'm not sure if I have the latest commit. Installed through Melpa.

mrcnski avatar Dec 19 '18 12:12 mrcnski

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.

srijan avatar Nov 12 '22 09:11 srijan

Yea, it must be related to something else. Maybe a race condition and the above commit just reduces the chances of it triggering?

alanhamlett avatar Nov 12 '22 18:11 alanhamlett

Running into this issue as well.

anoduck avatar Mar 17 '23 22:03 anoduck

'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 avatar Jan 23 '24 09:01 h2oota

@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.

anoduck avatar Jan 26 '24 07:01 anoduck

Added the patch with aa04a5551e782992ddaea890d8547863b0d6ba60.

alanhamlett avatar Jan 26 '24 14:01 alanhamlett

Thanks @alanhamlett!

anoduck avatar Jan 29 '24 20:01 anoduck

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.

h2oota avatar Feb 02 '24 01:02 h2oota

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.

alanhamlett avatar Feb 03 '24 12:02 alanhamlett