Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
x-ji opened this issue Sep 13, 2015 · 15 comments
Labels

Comments

@x-ji
Copy link

x-ji commented Sep 13, 2015

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

@incandescentman
Copy link

Same here.

@ashgillman
Copy link

Same also, Ubuntu w/ Emacs 24.5.3 and wakatime 1.0.2

@lockie
Copy link

lockie commented Aug 13, 2017

Same here, Gentoo, Emacs 25.2.1

@andrew-christianson
Copy link

andrew-christianson commented Sep 19, 2018

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.

@alanhamlett
Copy link
Member

Added the change with 2531cb5.

@mrcnski
Copy link

mrcnski commented Dec 19, 2018

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

@srijan
Copy link

srijan commented Nov 12, 2022

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.

@alanhamlett
Copy link
Member

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

@anoduck
Copy link

anoduck commented Mar 17, 2023

Running into this issue as well.

@h2oota
Copy link

h2oota commented Jan 23, 2024

'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"

@anoduck
Copy link

anoduck commented Jan 26, 2024

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

@alanhamlett
Copy link
Member

Added the patch with aa04a55.

@anoduck
Copy link

anoduck commented Jan 29, 2024

Thanks @alanhamlett!

@h2oota
Copy link

h2oota commented Feb 2, 2024

Thanks @alanhamlett!. It works perfectory.

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.

@alanhamlett
Copy link
Member

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 25fb775.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants