Error when used in combination with dashboard showing bookmarks
I'm not sure whether this is a problem with copilot or with dashboard, but I get the following error when starting emacs (copying the entire *Messages* buffer):
Copilot agent started.
For information about GNU Emacs and the GNU system, type C-h C-a.
Error running timer: (error "Selecting deleted buffer")
My init.el is (after stripping out everything unrelated to copilot and dashboard):
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name
"straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq native-comp-async-report-warnings-errors 'silent)
(require 'package)
(setq package-archives '(("elpa" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")))
(package-initialize)
(unless package-archive-contents (package-refresh-contents))
(unless (package-installed-p 'use-package) (package-install 'use-package))
(require 'use-package)
(use-package no-littering) ;; removing this fixes the issue, but also makes bookmark list on dashboard empty
(use-package dashboard
:config
(dashboard-setup-startup-hook) ;; removing this hook fixes the error, even if dashboard is manually opened
(setq dashboard-items '((bookmarks . 1))) ;; removing bookmarks from dashboard fixes the error )
(use-package copilot
:straight (:host github :repo "copilot-emacs/copilot.el" :files ("dist" "*.el"))
:hook (prog-mode . copilot-mode)) ;; removing this hook fixes the error
And my emacs --version says (on Ubuntu 22.04, installed via snap):
GNU Emacs 29.2
Development version da49e6d3b63e on master branch; build date 2024-01-29.
Copyright (C) 2024 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
I'm not sure what causes it, but it has something to do with dashboard opening on startup and displaying a bookmark list. I at least hope the error is reproducable.
I'm the maintainer of the dashboard and copilot. My best guess is the dashboard is trying to display some buffers, and that triggers the copilot. 🤔 Try to configure it so they don't conflict with each other. For example, I trigger copilot in find-file-hook since it's safer and you will get faster start-up time.
@jcs090218 Wow, big fan of you work!
Unfortunately, replacing prog-mode . copilot-mode with find-file . copilot-mode in the init.el that I posted doesn't fix the issue for me, but I guess I can configure copilot to only start when I open certain file endings or in certain modes.
I'm glad you've found a workaround! I suggest you defer your packages as many as possible. Dashboard issues are often pretty hard to track since anything could affect the result.
If you really want to resolve this issue, can you try M-x toggle-debug-on-error and paste the backtrace here? It should give you more details regarding the bug itself.
Sadly, starting emacs with --debug-init doesn't catch the error, and I have yet to recreate the error after startup, so M-x toggle-debug-on-error will not help either. But I will keep that in mind in case I ever come across it while using emacs!
@YueRen emacs --eval '(toggle-debug-on-error)' should work (i.e., give you an appropriate *Backtrace* buffer).
@hab25 Thanks for the tip! Unfortunately, emacs --eval '(toggle-debug-on-error)' doesn't start dashboard on startup for whatever reason so I cannot reproduce the error with it. :-/