reddit / emacs

Even after installing flycheck, symbol definition `global-flycheck-mode` is void

CaterpillarNo2326 · 2022-10-09 12:29
I added flycheck onto the list `package-selected-packages` and ran `(package-install-selected-packages)` after reopening Emacs: (setq package-selected-packages '(use-package lsp-mode lsp-ui lsp-treemacs dap-mode company-mode flycheck prism aggressive-indent haskell-mode lsp-haskell)) Then, I added this to my init.el (I use use-package): (use-package flycheck :init (global-flycheck-mode)) However, even after doing that, when I open Emacs, I still get this error: Error (use-package): flycheck/:init: Symbol’s function definition is void: global-flycheck-mode It's strange, because even though I installed flycheck, the function seems to be undefined. The use-package configuration is what they recommend on their [website](https://www.flycheck.org/en/latest/user/installation.html#package-installation), as well (scroll to find the use-package section), so I don't think the problem is calling `(global-flycheck-mode)`. Does anyone have tips for what I should do next?
azynheira · 2022-10-09 14:01
Put global-flycheck-mode in the :config part of use-package. : init is called before the package is loaded. :config is after. That's why its not defined.
CaterpillarNo2326 · 2022-10-09 14:07
Thanks for pointing that out! I didn't realize it was something that simple, but I'm glad it was.
eleven_cupfuls · 2022-10-10 18:48
Another good option, for a mode like this that doesn't need to be active *during* startup, is to use the `after-init-hook`: (use-package flycheck :defer t :hook (after-init . global-flycheck-mode))
CaterpillarNo2326 · 2022-10-11 00:16
Thanks for the tip! I may add that to more packages, if they're global.