Error message
The emacs plugin wakatime shows the following error message when save file each time.
error in process sentinel: progn: WakaTime Error (2)
error in process sentinel: WakaTime Error (2)
error in process sentinel: progn: WakaTime Error (2)
error in process sentinel: WakaTime Error (2)
Debug
Turn on the debug
M-x toggle-debug-on-error
The *backtrace* content
Debugger entered--Lisp error: (error "WakaTime Error (2)")
signal(error ("WakaTime Error (2)"))
error("WakaTime Error (%s)" 2)
(progn (error "WakaTime Error (%s)" exit-status))
(if (and (not (= 0 exit-status)) (not (= 102 exit-status))) (progn (error "WakaTime Error (%s)" exit-status)))
(when (and (not (= 0 exit-status)) (not (= 102 exit-status))) (error "WakaTime Error (%s)" exit-status))
(let ((exit-status (process-exit-status process))) (when (and (not (= 0 exit-status)) (not (= 102 exit-status))) (error "WakaTime Error (%s)" exit-status)) (when (= 102 exit-status) (if nil (error "WakaTime Error (%s)" exit-status) (wakatime-prompt-api-key) (wakatime-call nil t))))
(progn (kill-buffer (process-buffer process)) (let ((exit-status (process-exit-status process))) (when (and (not (= 0 exit-status)) (not (= 102 exit-status))) (error "WakaTime Error (%s)" exit-status)) (when (= 102 exit-status) (if nil (error "WakaTime Error (%s)" exit-status) (wakatime-prompt-api-key) (wakatime-call nil t)))))
(if (memq (process-status process) (quote (exit signal))) (progn (kill-buffer (process-buffer process)) (let ((exit-status (process-exit-status process))) (when (and (not (= 0 exit-status)) (not (= 102 exit-status))) (error "WakaTime Error (%s)" exit-status)) (when (= 102 exit-status) (if nil (error "WakaTime Error (%s)" exit-status) (wakatime-prompt-api-key) (wakatime-call nil t))))))
(when (memq (process-status process) (quote (exit signal))) (kill-buffer (process-buffer process)) (let ((exit-status (process-exit-status process))) (when (and (not (= 0 exit-status)) (not (= 102 exit-status))) (error "WakaTime Error (%s)" exit-status)) (when (= 102 exit-status) (if nil (error "WakaTime Error (%s)" exit-status) (wakatime-prompt-api-key) (wakatime-call nil t)))))
(lambda (process signal) (when (memq (process-status process) (quote (exit signal))) (kill-buffer (process-buffer process)) (let ((exit-status (process-exit-status process))) (when (and (not (= 0 exit-status)) (not (= 102 exit-status))) (error "WakaTime Error (%s)" exit-status)) (when (= 102 exit-status) (if nil (error "WakaTime Error (%s)" exit-status) (wakatime-prompt-api-key) (wakatime-call nil t))))))(#<process Shell> "exited abnormally with code 2\n")
Go to the wakatime source file wakatime-mode.el, and find the position which the error happen.
(defun wakatime-call (command)
"Call WakaTime COMMAND."
(let*
(
(process-environment (if wakatime-python-path
(cons (format "PYTHONPATH=%s" wakatime-python-path) process-environment)
process-environment))
(process
(start-process
"Shell"
(generate-new-buffer " *WakaTime messages*")
shell-file-name
shell-command-switch
command
)
)
)
(set-process-sentinel process
(lambda (process signal)
(when (memq (process-status process) '(exit signal))
(kill-buffer (process-buffer process))
(let ((exit-status (process-exit-status process)))
(when (and (not (= 0 exit-status)) (not (= 102 exit-status)))
(error "WakaTime Error (%s)" exit-status)
)
)
)
)
)
(set-process-query-on-exit-flag process nil)
)
)
Find the origin wakatime-call function caller
(defun wakatime-save ()
"Send save notice to WakaTime."
(when (buffer-file-name (current-buffer))
(wakatime-call (wakatime-client-command t))))
Execute (wakatime-client-command t) in *ielm* (M-x ielm)
ELISP> (wakatime-client-command t)
"/usr/bin/python2 /usr/local/bin/wakatime --file \"nil\" --write --plugin emacs-wakatime/1.0.2 --key e191899f-9e2a-4d00-8100-4e9f9523fedb --time 1476063658.33"
Here, we find that wakatime plugin executes a command in subprocess. So, we can execute in terminal manually:
➜ ~ /usr/bin/python2 /usr/local/bin/wakatime --file \"nil\" --write --plugin emacs-wakatime/1.0.2 --key e191899f-9e2a-4d00-8100-4e9f9523fedb --time 1476063658.33
Error: Could not read from config file /home/aborn/.wakatime.cfg
Solution
The really reason is Could not read from config file /home/aborn/.wakatime.cfg. Then we manually create the file /home/aborn/.wakatime.cfg with its content:
[settings]
api_key = e191899f-9e2a-4d00-8100-4e9f9523fedb
Note: pls replace api_key with your wakatime api_key.