175 lines
6.2 KiB
Plaintext
Executable File
175 lines
6.2 KiB
Plaintext
Executable File
#!/bin/sh
|
|
":"; exec emacs --no-site-file --script "$0" -- "$@" # -*-emacs-lisp-*-
|
|
|
|
;; Uses a couple simple heuristics to locate issues with your environment that
|
|
;; could interfere with running or setting up DOOM Emacs.
|
|
|
|
(defconst IS-MAC (eq system-type 'darwin))
|
|
|
|
(require 'package)
|
|
(load "~/.emacs.d/core/autoload/message" nil t)
|
|
|
|
(unless (equal (expand-file-name user-emacs-directory)
|
|
(expand-file-name "~/.emacs.d/"))
|
|
(error "Couldn't find ~/.emacs.d"))
|
|
|
|
;;
|
|
(defvar doom-errors 0)
|
|
(defmacro check! (cond &rest body)
|
|
(declare (indent defun))
|
|
`(when ,cond
|
|
,@body
|
|
(setq doom-errors (1+ doom-errors))))
|
|
|
|
(defun indented (spc msg)
|
|
(declare (indent defun))
|
|
(with-temp-buffer
|
|
(insert msg)
|
|
(indent-rigidly (point-min) (point-max) spc)
|
|
(buffer-string)))
|
|
|
|
(defun autofill (&rest msgs)
|
|
(declare (indent defun))
|
|
(let ((fill-column 70))
|
|
(with-temp-buffer
|
|
(dolist (line msgs)
|
|
(when line
|
|
(insert line)))
|
|
(fill-region (point-min) (point-max))
|
|
(buffer-string))))
|
|
|
|
(defun columns (cols length strings)
|
|
(declare (indent defun))
|
|
(with-temp-buffer
|
|
(let ((sub-format (format "%%-%ds " (1- length)))
|
|
col-format)
|
|
(dotimes (i (1- cols))
|
|
(setq col-format (concat col-format sub-format)))
|
|
(setq col-format (concat col-format "%s"))
|
|
(while strings
|
|
(insert (apply #'format col-format
|
|
(let (args)
|
|
(dotimes (i cols (nreverse args))
|
|
(push (if strings (pop strings) "") args))))
|
|
"\n")))
|
|
(buffer-string)))
|
|
|
|
(defmacro error! (&rest args) `(message! (bold (red ,@args))))
|
|
(defmacro warn! (&rest args) `(message! (bold (yellow ,@args))))
|
|
(defmacro success! (&rest args) `(message! (bold (green ,@args))))
|
|
(defmacro explain! (&rest args) `(message! (indented 2 (autofill ,@args))))
|
|
|
|
;;
|
|
(message! "%s\nRunning Emacs %s on %s\n----\n"
|
|
(bold "DOOM Doctor")
|
|
(bold emacs-version)
|
|
(bold "%s" system-type))
|
|
|
|
|
|
;; --- is emacs set up properly? ------------------------------
|
|
|
|
(check! (version< emacs-version "25.1")
|
|
(error! "Important: Emacs %s detected [%s]" emacs-version (executable-find "emacs"))
|
|
(explain!
|
|
"DOOM only supports >= 25.1. Perhaps your PATH wasn't set up properly."
|
|
(when IS-MAC
|
|
(concat "\nMacOS users should use homebrew (https://brew.sh) to install Emacs\n"
|
|
" brew install emacs --with-modules --with-imagemagick --with-cocoa"))))
|
|
|
|
|
|
;; --- is the environment set up properly? --------------------
|
|
|
|
(check! (not (executable-find "git"))
|
|
(error! "Important: Couldn't find git"))
|
|
|
|
(check! (memq system-type '(windows-nt ms-dos cygwin))
|
|
(warn! "Warning: Windows detected")
|
|
(explain! "DOOM was designed for MacOS and Linux. Expect a bumpy ride!"))
|
|
|
|
(if (executable-find "tar")
|
|
(check! (not (string-match-p "(GNU tar)" (shell-command-to-string "tar --version")))
|
|
(warn! "Warning: BSD tar detected")
|
|
(explain!
|
|
"QUELPA (through package-build) uses the system tar to build plugins."
|
|
"BSD tar *could* cause errors during package installation or updating from"
|
|
"non-ELPA sources."
|
|
(when IS-MAC
|
|
(concat "\nMacOS users can install gnu-tar via homebrew:\n"
|
|
" brew install gnu-tar"))))
|
|
(check! nil (error! "Important: Couldn't find tar"))) ; very unlikely
|
|
|
|
(check! (not (executable-find "gnutls-cli"))
|
|
(cond ((executable-find "openssl")
|
|
(warn! "Warning: couldn't find gnutls-cli")
|
|
(explain! "...but found openssl (which is possibly less secure)"))
|
|
(t
|
|
(error! "Warning: neither gnutls-cli or openssl were found")
|
|
(explain! "You will be unable to install/update packages through secure sources (HTTPS)"))))
|
|
|
|
|
|
;; --- report! ------------------------------------------------
|
|
|
|
(when (getenv "DEBUG")
|
|
(message! "\n====\nHave some debug information:\n")
|
|
|
|
(let (doom-core-packages doom-debug-mode)
|
|
(condition-case ex
|
|
(progn
|
|
(let ((inhibit-message t))
|
|
(load "~/.emacs.d/core/core.el" nil t))
|
|
(doom-initialize-packages)
|
|
(success! " + Attempt to load DOOM: success! Loaded v%s" doom-version)
|
|
(when (executable-find "git")
|
|
(message! " Revision %s"
|
|
(or (ignore-errors
|
|
(let ((default-directory user-emacs-directory))
|
|
(shell-command-to-string "git rev-parse HEAD")))
|
|
"\n"))))
|
|
('error (warn! " + Attempt to load DOOM: failed\n %s\n" (or (cdr-safe ex) (car ex))))))
|
|
|
|
(message! " + Emacs directory: %s\n" user-emacs-directory)
|
|
|
|
(when (bound-and-true-p doom-modules)
|
|
(message! " + enabled modules:\n%s"
|
|
(indented 4
|
|
(columns 3 23
|
|
(mapcar (lambda (x) (format "+%s" x))
|
|
(mapcar #'cdr (doom--module-pairs)))))))
|
|
|
|
(when (bound-and-true-p doom-packages)
|
|
(message! " + enabled packages:\n%s"
|
|
(indented 4
|
|
(columns 2 35
|
|
(mapcar (lambda (pkg)
|
|
(let ((desc (cadr (assq pkg package-alist))))
|
|
(when desc
|
|
(package-desc-full-name desc))))
|
|
(sort (mapcar #'car doom-packages) #'string-lessp))))))
|
|
|
|
(message! " + byte-compiled files:\n%s"
|
|
(indented 4
|
|
(columns 2 39
|
|
(let ((files (append (directory-files-recursively doom-core-dir ".elc$")
|
|
(directory-files-recursively doom-modules-dir ".elc$"))))
|
|
(or (and files (mapcar (lambda (file) (file-relative-name file doom-emacs-dir))
|
|
(nreverse files)))
|
|
(list "n/a"))))))
|
|
|
|
(message! " + exec-path:\n%s"
|
|
(indented 4
|
|
(columns 1 79 exec-path)))
|
|
|
|
(message! " + PATH:\n%s"
|
|
(indented 4
|
|
(columns 1 79 (split-string (getenv "PATH") ":")))))
|
|
|
|
;;
|
|
(if (= doom-errors 0)
|
|
(success! "Everything seems fine, happy Emacs'ing!")
|
|
(message "\n----")
|
|
(warn! "There were issues!")
|
|
(unless (getenv "DEBUG")
|
|
(message! "\nHopefully these can help you find problems. If not, run this doctor again with DEBUG=1:")
|
|
(message! "\n DEBUG=1 make doctor\n")
|
|
(message! "And file a bug report with its output at https://github.com/hlissner/.emacs.d/issues")))
|