From cb86a6721f7a29b89b21f4baf6ca43586eb91176 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Thu, 20 Aug 2020 22:14:42 +0100 Subject: [PATCH] fix(native_comp): automatically delete invalid *.eln files on startup If native compilation is interrupted by quitting Emacs, or if it otherwise fails, it can leave empty *.eln files behind which have a zero byte file size. Any such files will prevent Emacs from launching if not removed. This automates the removal of those files. --- early-init.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/early-init.el b/early-init.el index a183e49..01397f2 100644 --- a/early-init.el +++ b/early-init.el @@ -11,8 +11,14 @@ comp-deferred-compilation t) (when (boundp 'comp-eln-load-path) - (add-to-list 'comp-eln-load-path - (expand-file-name "cache/eln-cache/" user-emacs-directory))) + (let ((eln-cache-dir (expand-file-name "cache/eln-cache/" user-emacs-directory)) + (find-exec (executable-find "find"))) + (add-to-list 'comp-eln-load-path eln-cache-dir) + ;; Quitting emacs while native compilation in progress can leave zero byte + ;; sized *.eln files behind. Hence delete such files during startup. + (when find-exec + (call-process find-exec nil nil nil eln-cache-dir + "-name" "*.eln" "-size" "0" "-delete")))) ;; Defer garbage collection further back in the startup process (setq gc-cons-threshold most-positive-fixnum)