0

I added the following at the end of my ~/.spacemacs file:

(use-package flycheck
  :defer t
  :init (global-flycheck-mode))

When I do this, I get Spacemacs encountered an error while loading your '/home/brandon/.spacemacs' file.

How can I debug this error?

Also, is there a way to get more descriptive errors?

Answer to error sub-question in comments: use emacs --debug-init.

Update

The output I get when using --debug-init is:

Debugger entered--Lisp error: (void-function use-package)
  (use-package flycheck :defer t :init (global-flycheck-mode))
  eval-buffer(#<buffer  *load*-76993> nil "/home/brandon/.spacemacs" nil t)  ; Reading at buffer position 18437
  load-with-code-conversion("/home/brandon/.spacemacs" "/home/brandon/.spacemacs" nil nil)
  load("/home/brandon/.spacemacs")
  (condition-case err (load dotspacemacs) ((debug error) (message "Error loading .spacemacs: %S" err) nil))
  (if (condition-case err (load dotspacemacs) ((debug error) (message "Error loading .spacemacs: %S" err) nil)) nil (dotspacemacs/safe-load))
  (if (file-exists-p dotspacemacs) (if (condition-case err (load dotspacemacs) ((debug error) (message "Error loading .spacemacs: %S" err) nil)) nil (dotspacemacs/safe-load)))
  (let ((dotspacemacs (dotspacemacs/location))) (if (file-exists-p dotspacemacs) (if (condition-case err (load dotspacemacs) ((debug error) (message "Error loading .spacemacs: %S" err) nil)) nil (dotspacemacs/safe-load))))
  dotspacemacs/load-file()
  spacemacs/init()
  (if (not (version<= spacemacs-emacs-min-version emacs-version)) (error (concat "Your version of Emacs (%s) is too old. " "Spacemacs requires Emacs version %s or above.") emacs-version spacemacs-emacs-min-version) (load-file (concat (file-name-directory load-file-name) "core/core-load-paths.el")) (require 'core-spacemacs) (spacemacs/init) (configuration-layer/sync) (spacemacs-buffer/display-startup-note) (spacemacs/setup-startup-hook) (require 'server) (if (server-running-p) nil (server-start)))
  eval-buffer(#<buffer  *load*> nil "/home/brandon/.emacs.d/init.el" nil t)  ; Reading at buffer position 1264
  load-with-code-conversion("/home/brandon/.emacs.d/init.el" "/home/brandon/.emacs.d/init.el" t t)
  load("/home/brandon/.emacs.d/init" t t)
  #f(compiled-function () #<bytecode 0x25d5e9>)()
  command-line()
  normal-top-level()

Tentative Solution

After looking around a bit more, I realized my config was in the wrong part of the ~/.spacemacs file. This is probably not the best place for it, but I ended up adding the following in my (defun dotspacemacs/user-config () ... ).

(use-package flycheck
  :ensure t
  :init (global-flycheck-mode))

Also, I now note that flycheck complains that the line with (use-package flycheck has a reference to free variableflycheck' (emacs-lisp)` ... hmm. But, a step in the right direciton.

  • 1
    Try the debugging suggestions here: github.com/syl20bnr/spacemacs/wiki/… In particular, try starting spacemacs from the command line with the --debug-init option to get a backtrace. – MTS Jan 16 at 21:33
  • Thanks for the wiki link, things are working now, though still not sure I've gotten the best approach. Seems like I should try to understand layers more (as well as emacs lisp). – bbarker Jan 17 at 16:09
  • In use-package the :init keyword is for code to be executed before the package is loaded. We can assume global-flycheck-mode is defined in the package, if it is being found, it is probably for some other reason. So, you should probably move that to :config and remove :defer if I understand what you want correctly. But your error message complains about use-package being undefined. Have you loaded use-package itself in your init file? – gusbrs Jan 19 at 15:30

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.