7

I have 2 files in the same directory, say a.el and a-test.el.

a.el

;; some functions
(provide 'a)

a-test.el

(require 'a)

flycheck put a warning on the require in a-test.el says

Cannot open load files: a

How do I make flycheck find the required file in the same directory ?

Rangi Lin
  • 9,303
  • 6
  • 45
  • 71

1 Answers1

16

Flycheck does not use load-path when checking Emacs Lisp files. Instead, it uses flycheck-emacs-lisp-load-path, which is empty by default.

To make Flycheck use the current load-path, add the following to your init.el:

(setq-default flycheck-emacs-lisp-load-path 'inherit)

However, I recommend to use Cask in your projects, and then install flycheck-cask, to automatically use the right load path and package directory in Emacs Lisp projects.

  • My current flycheck setup [init.el#L58-L65](https://github.com/RangiLin/emacs.d/blob/master/init.el#L58-L65), but still have no luck :( – Rangi Lin Dec 11 '13 at 15:56
  • Obviously you need a Cask file in your project, and you need to use packages. If it's just for init.el, Cask might be overkill. Just set the aforementioned variable then. –  Dec 11 '13 at 16:22