bbatsov / prelude

Prelude is an enhanced Emacs 25.1+ distribution that should make your experience with Emacs both more pleasant and more powerful.
https://prelude.emacsredux.com
5.11k stars 1.85k forks source link

Error on startup when using the sample `prelude-modules.el` file #1387

Closed dduugg closed 1 year ago

dduugg commented 1 year ago

Expected behavior

Emacs starts normally when using the default prelude-modules.el file.

Actual behavior

Emacs reports an error:

Warning (initialization): An error occurred while loading ‘~/.emacs.d/init.el’:

Symbol's function definition is void: prelude-require-packages

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

(The error message persists using various subsets of the sample file, including reducing it to a single (require 'prelude-c) line)

Steps to reproduce the problem

Install Prelude via the "Fast Forward" method:

$ curl -L https://git.io/epre | sh

Start emacs, allow packages to install. Now, adopt the sample prelude-modules.el:

cp ~/.emacs.d/sample/prelude-modules.el ~/.emacs.d/personal/preload/

Now, when I restart emacs, I see the error above.

In case it's helfpul, restarting emacs with --debug-init results in:

Debugger entered--Lisp error: (void-function prelude-require-packages)
  (prelude-require-packages '(ivy swiper counsel))
  eval-buffer(#<buffer  *load*-759256> nil "~/.emacs.d/modules/prelud..." nil t)  ; Reading at buffer position 1284
  load-with-code-conversion("~/.emacs.d/modules/prelud..." "~/.emacs.d/modules/prelud..." nil t)
  require(prelude-ivy)
  eval-buffer(#<buffer  *load*-699396> nil "~/.emacs.d/personal/prelo..." nil t)  ; Reading at buffer position 1636
  load-with-code-conversion("~/.emacs.d/personal/prelo..." "~/.emacs.d/personal/prelo..." nil nil)
  load("~/.emacs.d/personal/prelo...")
  mapc(load ("~/.emacs.d/personal/prelo..."))
  (progn (message "[Prelude] Loading personal configuration files in ..." prelude-personal-preload-dir) (mapc 'load (directory-files prelude-personal-preload-dir 't "^[^#.].*el$")))
  (if (file-exists-p prelude-personal-preload-dir) (progn (message "[Prelude] Loading personal configuration files in ..." prelude-personal-preload-dir) (mapc 'load (directory-files pre$
  eval-buffer(#<buffer  *load*> nil "~/.emacs.d/init.el" nil t)  ; Reading at buffer position 4489
  load-with-code-conversion("~/.emacs.d/init.el" "~/.emacs.d/init.el" t t)
  load("~/.emacs.d/init" noerror nomessage)
  startup--load-user-init-file(#f(compiled-function () #<bytecode -0x148f927a7637463>) #f(compiled-function () #<bytecode -0x1f3c686ddc6f5435>) t)
  command-line()
  normal-top-level()

Environment & Version information

The error above led me to think that one of the packages being required (ivy swiper counsel) was possibly missing, but that doesn't seem to be the case:

➞  ls ~/.emacs.d/elpa                                                                                                                                                     [git:master] ✔
ace-window-20220911.358            easy-kill-20220511.557             hl-todo-20221011.1032              markdown-mode-20221105.236         spinner-1.7.4
ag-20201031.2202                   editorconfig-20221031.547          ht-20221031.705                    marshal-20201223.1853              super-save-20220531.1745
anzu-20211002.2255                 elisp-slime-nav-20210510.528       imenu-anywhere-20210201.1704       move-text-20221006.1634            swiper-20220430.2247
archives                           epl-20180205.2049                  ivy-20220926.1250                  nlinum-1.9                         transient-20221028.1430
avy-20220910.1936                  exec-path-from-shell-20220826.1535 js2-mode-20221028.1819             operate-on-number-20150707.623     undo-tree-0.8.2
browse-kill-ring-20220410.1509     expand-region-20221030.957         json-mode-20211011.630             pcache-20220724.1841               volatile-highlights-20160612.155
company-20221007.2145              f-20220911.711                     json-snatcher-20200916.1717        pkg-info-20150517.1143             web-mode-20221012.800
compat-28.1.2.2                    flycheck-20221104.549              logito-20201226.534                projectile-20221105.1641           which-key-20220811.1616
counsel-20221015.936               gh-20220302.549                    lsp-mode-20221104.1904             queue-0.2                          with-editor-20220810.1159
crux-20210811.436                  gist-20171128.406                  lsp-ui-20220924.850                rainbow-delimiters-20210515.1254   yaml-mode-20221022.920
dash-20221013.836                  git-commit-20221101.2237           lv-20200507.1518                   rainbow-mode-1.0.6                 zenburn-theme-20220927.631
diff-hl-20221007.2147              git-modes-20220422.1611            magit-20221101.2214                s-20220902.1511                    zop-to-char-20160212.1554
diminish-20220909.847              git-timemachine-20220920.828       magit-section-20220929.1014        smartparens-20220623.1523
discover-my-major-20180606.511     guru-mode-20211025.1157            makey-20131231.1430                smartrep-20150509.230

Emacs version

28.2

Operating system

macOS Monterey 12.6.1

bbatsov commented 1 year ago

It's defined early in https://github.com/bbatsov/prelude/blob/master/init.el and the code hasn't been changed in ages.

bbatsov commented 1 year ago

My bad - it's actually here https://github.com/bbatsov/prelude/blob/master/core/prelude-packages.el#L103

dduugg commented 1 year ago

@bbatsov Thanks for your reply. I think the issue is that prelude-packages isn't loaded until line 109 of init-el. However, I believe that prelude-modules.el is loaded in lines 102-104.

When I load personal settings after core, the error goes away. As you mentioned though, the code hasn't been changed in ages, so possibly there is something else at issue. Do you have any thoughts?

dduugg commented 1 year ago

This is resolved – the mistake here was moving ~/.emacs.d/sample/prelude-modules.el into ~/.emacs.d/personal/preload/ rather than just ~/.emacs.d/personal/. (I think I misread preload as prelude after working too long without a break 🤕).