Once every hour, or when I open a new file; I am usually getting error related to reading undo-tree history, which lead emacs daemon to frozen, and everytime I have to re-start the emacs.

The error I am having, where Emacs get frozen:

Error reading undo-tree history from "/home/alper/.emacs.d/undo/.!home!alper!personalize!emacs_q_git_edit.el.~undo-tree~"

How could I prevent emacs to get frozen due the Error reading undo-tree history from its file? Please note that when emacs frozen I was unable to debug it to invest it further.

The way I installed emacs:

mkdir -p ~/tools && cd ~/tools
git clone git://git.savannah.gnu.org/emacs.git && cd emacs
./configure --with-x-toolkit=yes --with-x-toolkit=no --with-native-compilation
make -j$(nproc)
sudo mkdir -p /opt/ss
sudo rm -f /opt/ss/*
sudo ln -s ~/tools/emacs/lib-src/emacsclient /opt/ss/
sudo ln -s ~/tools/emacs/src/emacs /opt/ss/

my configuration relevant to undo-tree, related:

(require 'undo-tree)
(setq undo-tree-auto-save-history t)
(global-undo-tree-mode t)
(setq undo-tree-auto-save-history t)
(setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo")))
(global-set-key "\C-x\C-v" 'undo-tree-visualize)
(require 'linum)
(defun undo-tree-visualizer-update-linum (&rest args)
    (linum-update undo-tree-visualizer-parent-buffer))
(advice-add 'undo-tree-visualize-undo :after #'undo-tree-visualizer-update-linum)
(advice-add 'undo-tree-visualize-redo :after #'undo-tree-visualizer-update-linum)
(advice-add 'undo-tree-visualize-undo-to-x :after #'undo-tree-visualizer-update-linum)
(advice-add 'undo-tree-visualize-redo-to-x :after #'undo-tree-visualizer-update-linum)
(advice-add 'undo-tree-visualizer-mouse-set :after #'undo-tree-visualizer-update-linum)
(advice-add 'undo-tree-visualizer-set :after #'undo-tree-visualizer-update-linum)

2 Answers 2


You can try to disable undo-in-region. It is buggy and responsible for slowing down.

(setq undo-tree-enable-undo-in-region nil)
  • Hopefully it will fix the problem I am having. I will update if I still face with the same error even undo-tree-enable-undo-in-region is disabled
    – alper
    Dec 17, 2021 at 19:57
  • I should do (setq undo-tree-enable-undo-in-region nil) right?
    – alper
    Dec 17, 2021 at 20:14
  • right. I updated the code in the message.
    – djangoliv
    Dec 18, 2021 at 19:53
  • Is there any way to kill undo-tree when this kind of bug frozes emacs?
    – alper
    Dec 19, 2021 at 15:05
  • not to my knowledge ...
    – djangoliv
    Dec 20, 2021 at 8:24

I had a similar issue, and I figure documenting my diagnostic process here might help people with this sort of problem, as it applies for other emacs issues.

I used ctrl-G to stop the save operation, then set the variable debug-on-quit to t, saved again and then hit ctrl-g to find the stack trace and find that the issue was caused by the undo-tree-mode.

I then ran m-x undo-tree-mode to disable the undo tree mode, which allowed me to save successfully.

After this I set debug-on-quit back to nil.

It's not a permanent fix, but lets me save without having to quit emacs, recompile or anything like that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.