               (error "✕ Couldn't install %s" package)))
           (message "Installing core packages...done"))))
     ;; autoloads file
-    (unless
-        (with-demoted-errors "Autoload error: %s"
-          (let (byte-compile-warnings)
-            (load doom-autoload-file 'noerror 'nomessage 'nosuffix)))
-      (unless noninteractive
-        (error "No autoloads file! Run make autoloads")))
-    (cl-pushnew doom-core-dir load-path :test #'string=))
+    (condition-case-unless-debug e
+        (unless
+            (let (byte-compile-warnings)
+              (load (substring doom-autoload-file 0 -3) 'noerror 'nomessage))
+          (error "No autoloads file! Run make autoloads"))
+      (error
+       (funcall (if noninteractive #'warn #'error)
+                "Autoload file error: %s -> %s" (car e) (error-message-string e))))
+    (add-to-list 'load-path doom-core-dir))
   ;; initialize Doom core
   (require 'core-os)
   (unless noninteractive

             (abbreviate-file-name file)))))
      (make-directory (file-name-directory doom-autoload-file) t)
      (let ((buf (find-file-noselect doom-autoload-file t))
            (load-path (append (list doom-emacs-dir)
                               doom-psuedo-module-dirs
                               doom-modules-dirs
                               load-path))
            library-cache)
        (unwind-protect
            (condition-case-unless-debug ex
                (with-current-buffer buf
                  (goto-char (point-min))
                  (insert ";;; -*- lexical-binding:t -*-\n"
                          ";; This file is autogenerated by `doom//reload-autoloads', DO NOT EDIT !!\n\n")

                  (save-excursion
                    ;; Replace autoload paths with absolute paths for faster
                    ;; resolution during load and simpler `load-path'
                    (while (re-search-forward "^\\s-*(autoload\\s-+'[^ ]+\\s-+\"\\([^/][^\"]*\\)\"" nil t)
                      (let ((path (match-string 1)))
                        ;; (delete-region (match-beginning 1) (match-end 1))
                        (replace-match
                         (or (cdr (assoc path library-cache))
                             (when-let* ((libpath (locate-library path))
                                         (libpath (file-name-sans-extension libpath)))
                               (push (cons path libpath) library-cache)
                               libpath)
                             (progn
                               (warn "Couldn't find absolute path for: %s" path)
                               path))
                         t t nil 1)))
                    (message "✓ Autoload paths expanded"))

                  (save-excursion
                    ;; insert package autoloads
                    (dolist (file (doom-packages--files doom-packages-dir "-autoloads\\.el$"))
                      (insert
                       (with-temp-buffer
                         (insert "\n(let ((load-file-name " (prin1-to-string file) "))")
                         (insert-file-contents file)
                         (while (re-search-forward "^;;\\(.*\n\\)" nil 'move)
                           (replace-match "" t t))
                         (unless (bolp) (insert "\n"))
                         (insert ")\n")
                         (buffer-string))))
                    (message "✓ Package autoloads included"))

                  ;; Replace autoload paths with absolute paths for faster
                  ;; resolution during load and simpler `load-path'
                  (while (re-search-forward "^\\s-*(add-to-list\\s-+'\\(?:load-path\\|auto-mode-alist\\)" nil t)
                    (beginning-of-line-text)
                    (kill-sexp))
                  (message "✓ Autoload load-path entries removed")

                  (save-buffer)
                  (let (byte-compile-warnings)
                    ;; give the file a chance to reveal errors
                    (load doom-autoload-file nil 'nomessage 'nosuffix))
                  (message "Done!"))
              ('error
               (delete-file doom-autoload-file)
               (error "Error in autoloads.el: %s -- %s"
                      (car ex) (error-message-string ex))))
          (kill-buffer buf))))))

(defun doom//byte-compile (&optional modules recompile-p)


(defvar doom-disabled-packages ()
  "A list of packages that should be ignored by `def-package!'.")

(defvar doom-autoload-excluded-packages '(marshal gh)
  "Packages that have silly or destructive autoload files that try to load
everyone in the universe and their dog, causing errors that make babies cry. No
one wants that.")

(defvar doom-reload-hook nil
  "A list of hooks to run when `doom/reload-load-path' is called.")
