0

I get the error: run-hooks: Autoloading file /home/xxxx/.emacs.d/elpa/evil-collection-20210203.811/modes/unimpaired/evil-collection-unimpaired.elc failed to define function evil at startup.

Here is the content of Backtrace

Debugger entered--Lisp error: (error "Autoloading file /home//.emacs.d/elpa/evil-20...")
  evil()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook emacs-lisp-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook emacs-lisp-mode-hook))
  run-mode-hooks(emacs-lisp-mode-hook)
  emacs-lisp-mode()
  set-auto-mode-0(emacs-lisp-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer init.el> "~/.emacs.d/init.el" nil nil "~/.emacs.d/init.el" (5991267 65027))
  find-file-noselect("/home/xxxxx/.emacs.d/init.el")
  custom-save-all()
  customize-save-variable(package-selected-packages (lsp-ui web-mode js2-mode lsp-mode ob-sagemath sage-shell-mode org-tree-slide hydra evil-collection evil-surround evil general helpful which-key rainbow-delimiters doom-themes doom-modeline all-the-icons counsel ivy-rich ivy command-log-mode use-package))
  package--save-selected-packages((lsp-ui web-mode js2-mode lsp-mode ob-sagemath sage-shell-mode org-tree-slide hydra evil-collection evil-surround evil general helpful which-key rainbow-delimiters doom-themes doom-modeline all-the-icons counsel ivy-rich ivy command-log-mode use-package))
  package-install(lsp-ui)
  use-package-ensure-elpa(lsp-ui (t) nil)
  (progn (use-package-ensure-elpa 'lsp-ui '(t) 'nil) (defvar use-package--warning25 #'(lambda (keyword err) (let ((msg (format "%s/%s: %s" ... keyword ...))) (display-warning 'use-package msg :error)))) (condition-case err (eval-after-load 'lsp-mode #'(lambda nil (progn (if (fboundp ...) nil (autoload ... "lsp-ui" nil t)) (eval-after-load 'lsp-ui #'...) (add-hook 'lsp-mode-hook #'lsp-ui-mode)))) ((debug error) (funcall use-package--warning25 :catch err))))
  eval((progn (use-package-ensure-elpa 'lsp-ui '(t) 'nil) (defvar use-package--warning25 #'(lambda (keyword err) (let ((msg ...)) (display-warning 'use-package msg :error)))) (condition-case err (eval-after-load 'lsp-mode #'(lambda nil (progn (if ... nil ...) (eval-after-load ... ...) (add-hook ... ...)))) ((debug error) (funcall use-package--warning25 :catch err)))) nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

Here is my evil config (I tried to post my entire config but SOF thinks it's spam. Is this good practice?):

..
;; Evil Mode
(defun lieut/evil-hook ()
  (dolist (mode '(custom-mode
          eshell-mode
          git-rebase-mode
          erc-mode
          circe-server-mode
          circe-chat-mode
          circe-query-mode
          sauron-mode
          term-mode))
    (add-to-list 'evil-emacs-state-modes mode)))


(use-package evil
  :ensure t
  :init
  (setq evil-want-integration t)
  (setq evil-want-keybinding nil)
  (setq evil-want-C-u-scroll t)
  (setq evil-want-C-i-jump nil)
  :hook
  prog-mode
  (evil-mode . lieut/evil-hook)
  :config
  (evil-mode 1)
  (define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state)
  (define-key evil-insert-state-map (kbd "C-h") 'evil-delete-backward-char-and-join)
  (define-key evil-insert-state-map (kbd "C-l") 'evil-delete-char)
  ;; Use visual line motions even outside of visual-line-mode buffers
  (evil-global-set-key 'motion "j" 'evil-next-visual-line)
  (evil-global-set-key 'motion "k" 'evil-previous-visual-line)

  (evil-set-initial-state 'messages-buffer-mode 'normal)
  (evil-set-initial-state 'dashboard-mode 'normal))

(use-package evil-surround
  :ensure t
  :after evil
  :config
  (global-evil-surround-mode 1))

(use-package evil-collection
  :after evil
  :ensure t
  :custom
  (evil-collection-outline-bind-tab-p nil)
  :config
  (evil-collection-init))


However, evil mode is working as intended. As you can see I use the :after header in use-package definitions to make sure evil loads first. If I remove the use-package declarations for evil-collections, I get the same error for evil-surround as well. Doing the same for evil-surround then makes the error occur for evil itself.

I was using emacs-xemacs at first, so I installed my distro's(Arch) version and deleted .emacs.d/ and I still get this error at startup.

I checked load-path and evil occurs after evil-collections and evil-surround. Is this the issue? If yes, how do I ensure that evil occurs before evil-collections?

Your Answer

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

Browse other questions tagged or ask your own question.