So it seems trivial: I (package-initialize) and (require) every package in dump.el , and everything works, except that it doesn’t. For one, load-path is not stored in the dump image . You need to store load-path in another variable.

;; in dump.el (package-initialize) ( setq luna-dumped-load-path load-path) ... (dump-emacs-portable "~/.emacs.d/emacs.pdmp" ) ;; in init.el ( setq load-path luna-dumped-load-path)

Second, when you start Emacs with a dump file, some default modes are not enabled:

transient-mark-mode

global-font-lock-mode

And global-undo-tree-mode makes Emacs segfault during dumping (didn’t verify, Spacemacs says so, but why would you enable it when dumping anyway?) Spacemacs also says winner-mode and global-undo-tree mode doesn’t live through dumping, but I enable them in my init.el , not in dump, so that doesn’t affect me.

The fix is simple, have something like this in init.el :

(global-font-lock-mode) (transient-mark-mode)

Third, you can’t use ~ in the --dump-file command line flag. Otherwise, Emacs complains about cannot open dump file. So don’t use ~/.emacs.d/emacs.pdmp . The dump file loads in very early stage, many variables are not known yet, so ~ won’t expand.

Fourth, scratch buffer behaves differently when Emacs starts with a dump file. Re-run mode hook seems to fix it:

(add-hook 'after-init-hook ( lambda () ( save-excursion (switch-to-buffer "*scratch*" ) (lisp-interaction-mode))))



As a side note (kindly provided by Damien Cassou), (a relatively new version of) Magit uses dynamic modules, which is not dumpable. So don’t require Magit in your dump. The portable dumper doesn’t dump window configurations either, but since I’m dumping only the packages, it doesn’t annoy me.

Now the dump.el is:

( require ' package ) ;; load autoload files and populate load-path’s (package-initialize) ;; store load-path ( setq luna-dumped-load-path load-path) ;; (package-initialize) doens’t require each package, we need to load ;; those we want manually ( dolist (package '(use-package company ivy counsel org helpful general helpful use-package general which-key recentf-ext swiper ivy-prescient find-char aggressive-indent windman doom-themes winner elec-pair doom-one-light-theme doom-cyberpunk-theme rainbow-delimiters highlight-parentheses hl-todo buffer-move savehist eyebrowse minions ws-butler expand-region isolate outshine flyspell magit eglot)) ( require package )) ;; dump image (dump-emacs-portable "xxx" )

init.el :