1

The way I installed undo-tree:

  • M-x package-install undo-tree

My setup:

  • GNU Emacs 26.3
  • undo-tree 0.7.4 installed Treat undo history as a tree
(global-undo-tree-mode 1)
(setq undo-tree-auto-save-history t)
(setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo")))

Error I am getting:

Warning (initialization): An error occurred while loading ‘/home/netlab/.emacs’:

Wrong type argument: undo-tree, [cl-struct-undo-tree [nil ([nil ([nil nil ((q . -1) (undo-tree-id0 . -1) 2) nil (24247 15636 187465 670000) 0
nil]) ((1 . 2) (t 24232 5976 416148 754000)) nil (24247 15636 187476 578000) 0 nil]) nil nil (24247 15636 187481 124000) 0 nil] [nil nil ((q .
-1) (undo-tree-id0 . -1) 2) nil (24247 15636 187465 670000) 0 nil] 41 2 nil]

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.

I am not sure how can I fix this error or what causing it.


Update:

Output of the debug output:

Debugger entered--Lisp error: (wrong-type-argument undo-tree [cl-struct-undo-tree [nil ([nil ([nil nil (... ...
2) nil (24247 15636 187465 670000) 0 nil]) ((1 . 2) (t 24232 5976 416148 754000)) nil (24247 15636 187476 578000)
0 nil]) nil nil (24247 15636 187481 124000) 0 nil] [nil nil ((#("q" 0 1 (fontified t)) . -1) (undo-tree-id0 . -1)
2) nil (24247 15636 187465 670000) 0 nil] 41 2 nil])
  signal(wrong-type-argument (undo-tree [cl-struct-undo-tree [nil ([nil ([nil nil ... nil ... 0 nil]) ((1 . 2) (t
24232 5976 416148 754000)) nil (24247 15636 187476 578000) 0 nil]) nil nil (24247 15636 187481 124000) 0 nil]
[nil nil ((#("q" 0 1 (fontified t)) . -1) (undo-tree-id0 . -1) 2) nil (24247 15636 187465 670000) 0 nil] 41 2
nil]))
  undo-tree-load-history(nil noerror)
  undo-tree-load-history-from-hook()
  run-hooks(find-file-hook)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer __init__.py> "~/folder/__init__.py" nil nil "~/folder/__init__.py"
(29887794 2050))
  find-file-noselect("/home/alper/folder/__init__.py")
  mapcar(find-file-noselect ("/home/alper/folder/Driver.py" "/home/alper/folder/__init__.py"
"/home/alper/folder/config.py" "/home/alper/folder/end_code.py"
"/home/alper/folder/garbageCollector.py" "/home/alper/folder/imports.py"
"/home/alper/folder/ipfs_daemon.py" "/home/alper/folder/lib.py" "/home/alper/folder/link.py"
"/home/alper/folder/setup.py" "/home/alper/folder/start_code.py"
"/home/alper/folder/thread_log.py" "/home/alper/folder/utils.py"
"/home/alper/folder/whisper_state_receiver.py"))
  find-file-noselect("*.py" nil nil t)
  find-file("*.py" t)
  eval-buffer(#<buffer  *load*> nil "/home/alper/.emacs" nil t)  ; Reading at buffer position 25178
  load-with-code-conversion("/home/alper/.emacs" "/home/alper/.emacs" t t)
  load("~/.emacs" t t)
  #f(compiled-function () #<bytecode 0x2967a1>)()
  command-line()
  normal-top-level()

desktop output:

  • If you remove the offending undo-tree saved history file relating to a buffer that Emacs is trying to open during startup, does Emacs start up properly? Another thing to check would be your desktop saved history file to see if it is storing undo-tree stuff relating to an open buffer -- if so, then try removing the desktop save history file and try restarting. – lawlist Jul 15 '20 at 0:16
  • ~.emacs.d/undo is empty. I am not sure which file should I remove and where is it located. This occurs when I try to open a empty file as well. Also where is desktop save history file located? – alper Jul 15 '20 at 0:24
  • If you are using the desktop.el save library to automatically load your last used layout, then evaluating the function desktop-full-file-name should tell you where it is located. E.g., M-x eval-expression RET (desktop-full-file-name) RET assuming that the desktop.el library has already been loaded. It should be somewhere in your user-emacs-directory, but could be elsewhere ... – lawlist Jul 15 '20 at 0:35
  • Did you try invoking emacs with emacs --debug-init as suggested in the message? If that gives you a backtrace, please add it to your question. – NickD Jul 15 '20 at 1:38
  • 1
    My undo-tree history saved file looks like this: /Users/HOME/.emacs.d/undo/.!Users!HOME!Desktop!__init__.py.~undo-tree~ Move that file to a different directory for potential deletion later, and then restart Emacs. – lawlist Jul 15 '20 at 18:15
3

A few years ago, I created a fork of undo-tree that was compatible with Emacs 25 (but not later/newer versions of Emacs) and I spent a considerable amount of time debugging in relation thereto. As part of that work, I inspected and debugged countless undo-tree saved history files -- that prior work helped me to identify the initial cursory debugging message and guess-timate the problem. Initial attempts at troubleshooting the problem in the comments underneath the question above were complicated because the O.P. had suppressed visibility of hidden files in the undo-tree saved history file directory, and the O.P. was under the initial misimpression that the directory was empty. It turned out that the saved undo-tree history file was indeed where it was supposed to be, just hidden from view. Deleting that file resolved the issue. It is possible to spend additional time trying to ascertain why the undo-tree saved history file became problematic, but we will leave that issue for another question at some point in the future (should the need arise).

@NickD requested a lengthier backtrace as suggested by the initial cursory debugging message; i.e., "Start Emacs with the --debug-init option to view a complete error backtrace." And once the O.P. provided that detailed backtrace, it became crystal clear where the problem was as mentioned hereinabove.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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