Improve bin/doctor's portability + revise feedback
This commit is contained in:
parent
2b5b09c39e
commit
22bab03692
1 changed files with 88 additions and 43 deletions
131
bin/doctor
131
bin/doctor
|
@ -1,13 +1,13 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env bash
|
||||||
":"; exec emacs --no-site-file --script "$0" -- "$@" # -*-emacs-lisp-*-
|
":"; command -v emacs >/dev/null || { >&2 echo "Emacs isn't installed"; exit 1; }
|
||||||
|
":"; [[ $(emacs --version | head -n1) == *\ 2[0-2].[0-1].[0-9] ]] && echo 'Emacs version is too old, check your PATH' || exec emacs --no-site-file --batch -l "$0" # -*-emacs-lisp-*-
|
||||||
|
|
||||||
;; Uses a couple simple heuristics to locate issues with your environment that
|
;; Uses a couple simple heuristics to locate issues with your environment that
|
||||||
;; could interfere with running or setting up DOOM Emacs.
|
;; could interfere with running or setting up DOOM Emacs.
|
||||||
|
|
||||||
(defconst IS-MAC (eq system-type 'darwin))
|
;; In case it isn't defined (in really old versions of Emacs, like the one that
|
||||||
|
;; ships with MacOS).
|
||||||
(require 'package)
|
(defvar user-emacs-directory (expand-file-name "~/.emacs.d/"))
|
||||||
(load "~/.emacs.d/core/autoload/message" nil t)
|
|
||||||
|
|
||||||
(unless (equal (expand-file-name user-emacs-directory)
|
(unless (equal (expand-file-name user-emacs-directory)
|
||||||
(expand-file-name "~/.emacs.d/"))
|
(expand-file-name "~/.emacs.d/"))
|
||||||
|
@ -54,18 +54,31 @@
|
||||||
"\n")))
|
"\n")))
|
||||||
(buffer-string)))
|
(buffer-string)))
|
||||||
|
|
||||||
(defmacro error! (&rest args) `(message! (bold (red ,@args))))
|
(defun color (code msg &rest args)
|
||||||
(defmacro warn! (&rest args) `(message! (bold (yellow ,@args))))
|
(format "\e[%dm%s\e[%dm" code (apply #'format msg args) 0))
|
||||||
(defmacro success! (&rest args) `(message! (bold (green ,@args))))
|
|
||||||
(defmacro explain! (&rest args) `(message! (indented 2 (autofill ,@args))))
|
|
||||||
|
|
||||||
;;
|
(defalias 'msg! #'message)
|
||||||
(message! "%s\nRunning Emacs v%s"
|
(defmacro error! (&rest args) `(message (color 1 (color 31 ,@args))))
|
||||||
(bold "DOOM Doctor")
|
(defmacro warn! (&rest args) `(message (color 1 (color 33 ,@args))))
|
||||||
(bold emacs-version))
|
(defmacro success! (&rest args) `(message (color 1 (color 32 ,@args))))
|
||||||
(message! "Compiled with:\n%s" (indented 2 (autofill system-configuration-features)))
|
(defmacro explain! (&rest args) `(message (indented 2 (autofill ,@args))))
|
||||||
(message! "uname -a:\n%s" (indented 2 (autofill (shell-command-to-string "uname -a"))))
|
|
||||||
(message "----\n")
|
;;; Polyfills
|
||||||
|
;; early versions of emacs won't have this
|
||||||
|
(unless (fboundp 'string-match-p)
|
||||||
|
(defun string-match-p (regexp string &optional start)
|
||||||
|
(save-match-data
|
||||||
|
(string-match regexp string &optional start))))
|
||||||
|
|
||||||
|
|
||||||
|
;; --- start a'doctorin' --------------------------------------
|
||||||
|
|
||||||
|
(msg! "%s\nRunning Emacs v%s"
|
||||||
|
(color 1 "DOOM Doctor")
|
||||||
|
(color 1 emacs-version))
|
||||||
|
(msg! "Compiled with:\n%s" (indented 2 (autofill system-configuration-features)))
|
||||||
|
(msg! "uname -a:\n%s" (indented 2 (autofill (shell-command-to-string "uname -a"))))
|
||||||
|
(msg! "----\n")
|
||||||
|
|
||||||
|
|
||||||
;; --- is emacs set up properly? ------------------------------
|
;; --- is emacs set up properly? ------------------------------
|
||||||
|
@ -74,20 +87,59 @@
|
||||||
(error! "Important: Emacs %s detected [%s]" emacs-version (executable-find "emacs"))
|
(error! "Important: Emacs %s detected [%s]" emacs-version (executable-find "emacs"))
|
||||||
(explain!
|
(explain!
|
||||||
"DOOM only supports >= 25.1. Perhaps your PATH wasn't set up properly."
|
"DOOM only supports >= 25.1. Perhaps your PATH wasn't set up properly."
|
||||||
(when IS-MAC
|
(when (eq system-type 'darwin)
|
||||||
(concat "\nMacOS users should use homebrew (https://brew.sh) to install Emacs\n"
|
(concat "\nMacOS users should use homebrew (https://brew.sh) to install Emacs\n"
|
||||||
" brew install emacs --with-modules --with-imagemagick --with-cocoa"))))
|
" brew install emacs --with-modules --with-imagemagick --with-cocoa"))))
|
||||||
|
|
||||||
|
|
||||||
;; --- is the environment set up properly? --------------------
|
;; --- is the environment set up properly? --------------------
|
||||||
|
|
||||||
(check! (not (executable-find "git"))
|
;; gnutls-cli & openssl
|
||||||
(error! "Important: Couldn't find git"))
|
(unless (not (executable-find "gnutls-cli"))
|
||||||
|
(cond ((executable-find "openssl")
|
||||||
|
(let* ((output (shell-command-to-string "openssl ciphers -v"))
|
||||||
|
(protocols
|
||||||
|
(let (protos)
|
||||||
|
(mapcar (lambda (row)
|
||||||
|
(add-to-list 'protos (cadr (split-string row " " t))))
|
||||||
|
(split-string (shell-command-to-string "openssl ciphers -v") "\n"))
|
||||||
|
(delq nil protos))))
|
||||||
|
(check! (not (or (member "TLSv1.1" protocols)
|
||||||
|
(member "TLSv1.2" protocols)))
|
||||||
|
(let ((version (cadr (split-string (shell-command-to-string "openssl version") " " t))))
|
||||||
|
(warn! "Warning: couldn't find gnutls-cli, and OpenSSL is out-of-date (v%s)" version)
|
||||||
|
(explain!
|
||||||
|
"This may not affect your Emacs experience, but there are security "
|
||||||
|
"vulnerabilities in the SSL2/3 & TLS1.0 protocols. You should use "
|
||||||
|
"TLS 1.1+, which wasn't introduced until OpenSSL v1.0.1.\n\n"
|
||||||
|
|
||||||
|
"Please considering updating (or installing gnutls-cli, which is preferred).")))))
|
||||||
|
(t
|
||||||
|
(check! t
|
||||||
|
(error! "Important: couldn't find either gnutls-cli or openssl")
|
||||||
|
(explain!
|
||||||
|
"You won't be able to install/update packages because Emacs won't be able to "
|
||||||
|
"verify HTTPS ELPA sources. Install gnutls-cli or openssl v1.0.0+. If for some "
|
||||||
|
"reason you can't, you can bypass this verification with the INSECURE flag:\n\n"
|
||||||
|
|
||||||
|
" INSECURE=1 make install\n\n"
|
||||||
|
|
||||||
|
"Or change `package-archives' to use non-https sources.\n\n"
|
||||||
|
|
||||||
|
"But remember that you're leaving your security in the hands of your "
|
||||||
|
"network, provider, government, neckbearded mother-in-laws, geeky roommates, "
|
||||||
|
"or just about anyone who knows more about computers than you do!")))))
|
||||||
|
|
||||||
|
;; git
|
||||||
|
(check! (not (executable-find "git"))
|
||||||
|
(error! "Important: couldn't find git"))
|
||||||
|
|
||||||
|
;; windows? windows
|
||||||
(check! (memq system-type '(windows-nt ms-dos cygwin))
|
(check! (memq system-type '(windows-nt ms-dos cygwin))
|
||||||
(warn! "Warning: Windows detected")
|
(warn! "Warning: Windows detected")
|
||||||
(explain! "DOOM was designed for MacOS and Linux. Expect a bumpy ride!"))
|
(explain! "DOOM was designed for MacOS and Linux. Expect a bumpy ride!"))
|
||||||
|
|
||||||
|
;; bsd vs gnu tar
|
||||||
(if (executable-find "tar")
|
(if (executable-find "tar")
|
||||||
(check! (not (string-match-p "(GNU tar)" (shell-command-to-string "tar --version")))
|
(check! (not (string-match-p "(GNU tar)" (shell-command-to-string "tar --version")))
|
||||||
(warn! "Warning: BSD tar detected")
|
(warn! "Warning: BSD tar detected")
|
||||||
|
@ -95,24 +147,18 @@
|
||||||
"QUELPA (through package-build) uses the system tar to build plugins."
|
"QUELPA (through package-build) uses the system tar to build plugins."
|
||||||
"BSD tar *could* cause errors during package installation or updating from"
|
"BSD tar *could* cause errors during package installation or updating from"
|
||||||
"non-ELPA sources."
|
"non-ELPA sources."
|
||||||
(when IS-MAC
|
(when (eq system-type 'darwin)
|
||||||
(concat "\nMacOS users can install gnu-tar via homebrew:\n"
|
(concat "\nMacOS users can install gnu-tar via homebrew:\n"
|
||||||
" brew install gnu-tar"))))
|
" brew install gnu-tar"))))
|
||||||
(check! nil (error! "Important: Couldn't find tar"))) ; very unlikely
|
(check! t ; very unlikely
|
||||||
|
(error! "Important: Couldn't find tar")
|
||||||
(check! (not (executable-find "gnutls-cli"))
|
(explain! "This is required by package.el and QUELPA to build packages.")))
|
||||||
(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! ------------------------------------------------
|
;; --- report! ------------------------------------------------
|
||||||
|
|
||||||
(when (getenv "DEBUG")
|
(when (getenv "DEBUG")
|
||||||
(message! "\n====\nHave some debug information:\n")
|
(msg! "\n====\nHave some debug information:\n")
|
||||||
|
|
||||||
(let (doom-core-packages doom-debug-mode)
|
(let (doom-core-packages doom-debug-mode)
|
||||||
(condition-case ex
|
(condition-case ex
|
||||||
|
@ -122,24 +168,23 @@
|
||||||
(doom-initialize-packages)
|
(doom-initialize-packages)
|
||||||
(success! " + Attempt to load DOOM: success! Loaded v%s" doom-version)
|
(success! " + Attempt to load DOOM: success! Loaded v%s" doom-version)
|
||||||
(when (executable-find "git")
|
(when (executable-find "git")
|
||||||
(message! " Revision %s"
|
(msg! " Revision %s"
|
||||||
(or (ignore-errors
|
(or (ignore-errors
|
||||||
(let ((default-directory user-emacs-directory))
|
(let ((default-directory user-emacs-directory))
|
||||||
(shell-command-to-string "git rev-parse HEAD")))
|
(shell-command-to-string "git rev-parse HEAD")))
|
||||||
"\n"))))
|
"\n"))))
|
||||||
('error (warn! " + Attempt to load DOOM: failed\n %s\n" (or (cdr-safe ex) (car ex))))))
|
('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)
|
(when (bound-and-true-p doom-modules)
|
||||||
(message! " + enabled modules:\n%s"
|
(msg! " + enabled modules:\n%s"
|
||||||
(indented 4
|
(indented 4
|
||||||
(columns 3 23
|
(columns 3 23
|
||||||
(mapcar (lambda (x) (format "+%s" x))
|
(mapcar (lambda (x) (format "+%s" x))
|
||||||
(mapcar #'cdr (doom--module-pairs)))))))
|
(mapcar #'cdr (doom--module-pairs)))))))
|
||||||
|
|
||||||
(when (bound-and-true-p doom-packages)
|
(when (and (bound-and-true-p doom-packages)
|
||||||
(message! " + enabled packages:\n%s"
|
(require 'package nil t))
|
||||||
|
(msg! " + enabled packages:\n%s"
|
||||||
(indented 4
|
(indented 4
|
||||||
(columns 2 35
|
(columns 2 35
|
||||||
(mapcar (lambda (pkg)
|
(mapcar (lambda (pkg)
|
||||||
|
@ -148,7 +193,7 @@
|
||||||
(package-desc-full-name desc))))
|
(package-desc-full-name desc))))
|
||||||
(sort (mapcar #'car doom-packages) #'string-lessp))))))
|
(sort (mapcar #'car doom-packages) #'string-lessp))))))
|
||||||
|
|
||||||
(message! " + byte-compiled files:\n%s"
|
(msg! " + byte-compiled files:\n%s"
|
||||||
(indented 4
|
(indented 4
|
||||||
(columns 2 39
|
(columns 2 39
|
||||||
(let ((files (append (directory-files-recursively doom-core-dir ".elc$")
|
(let ((files (append (directory-files-recursively doom-core-dir ".elc$")
|
||||||
|
@ -157,11 +202,11 @@
|
||||||
(nreverse files)))
|
(nreverse files)))
|
||||||
(list "n/a"))))))
|
(list "n/a"))))))
|
||||||
|
|
||||||
(message! " + exec-path:\n%s"
|
(msg! " + exec-path:\n%s"
|
||||||
(indented 4
|
(indented 4
|
||||||
(columns 1 79 exec-path)))
|
(columns 1 79 exec-path)))
|
||||||
|
|
||||||
(message! " + PATH:\n%s"
|
(msg! " + PATH:\n%s"
|
||||||
(indented 4
|
(indented 4
|
||||||
(columns 1 79 (split-string (getenv "PATH") ":")))))
|
(columns 1 79 (split-string (getenv "PATH") ":")))))
|
||||||
|
|
||||||
|
@ -171,6 +216,6 @@
|
||||||
(message "\n----")
|
(message "\n----")
|
||||||
(warn! "There were issues!")
|
(warn! "There were issues!")
|
||||||
(unless (getenv "DEBUG")
|
(unless (getenv "DEBUG")
|
||||||
(message! "\nHopefully these can help you find problems. If not, run this doctor again with DEBUG=1:")
|
(msg! "\nHopefully these can help you find problems. If not, run this doctor again with DEBUG=1:")
|
||||||
(message! "\n DEBUG=1 make doctor\n")
|
(msg! "\n DEBUG=1 make doctor\n")
|
||||||
(message! "And file a bug report with its output at https://github.com/hlissner/.emacs.d/issues")))
|
(msg! "And file a bug report with its output at https://github.com/hlissner/.emacs.d/issues")))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue