8

I have some elips *.el file in my ~/.emacs.d/gman/ folder, e.g. smart-inputp-methods.el. This folder is added to my load path at the beginning of .emacs file:

(add-to-list 'load-path "~/.emacs.d/gman")

Leter I importing it:

(require 'smart-input-methods)

Functions defined there successfully loaded, however Flycheck reports me error on that line, that file could not be found:

Cannot open load file: no such file or directory, smart-input-methods

This is quite annoying, how can I fix that?

Geradlus_RU
  • 625
  • 7
  • 17
  • The library for `flycheck` on Github does not have a file named `smart-input-methods.el` Why do you believe this is a valid file name? https://github.com/flycheck/flycheck Googling for `"smart-input-methods"` yields no results except for this particular thread -- which could mean that the file may not exist except in your own setup. If you created `smart-input-methods.el` for your own purposes, then you will need to put `(provide 'smart-input-methods)` at the bottom of the file in order to be able to use `require` later on. – lawlist Mar 23 '15 at 20:30
  • 6
    @lawlist He said flycheck is reporting "no such file" on that line, because that is what flycheck does (point out errors in lisp files), he's not saying that file is part of flycheck. He is asking why this error is being triggered even though the file is on his `load-path`. On a separate note, that error is caused when a file isn't found, not when a file is missing the `provide` statement (that is a different error). – Malabarba Mar 23 '15 at 23:49
  • @lawlist, **Malabarba** is right, I do have `provide` statement in my file. This script modifies internal Emacs keyboard layout to correspond with apple keyboard (when Russian input method selected). By the way, this error message also occurs when I `require` something installed from MELPA. – Geradlus_RU Mar 24 '15 at 03:16
  • 1
    Thank you both for helping to correct me -- I am always grateful to learn new aspects of Emacs. – lawlist Mar 24 '15 at 03:58
  • Could it be because there is no actually corresponding function in `smart-input-methods.el`? There is runnable code only, e.g. input method is being modified when file evaluated, I could share the code if needed. – Geradlus_RU Mar 24 '15 at 14:32

1 Answers1

13

Flycheck does simply not use your load-path for checking. By default, it always checks files in a clean environment, using only the built-in load-path of Emacs. IOW, Flycheck always checks in emacs -Q.

To make your custom code visible to Flycheck, you can either explicitly add all directories to flycheck-emacs-lisp-load-path as well, or set flycheck-emacs-lisp-load-path to inherit. In the latter case, Flycheck will automatically use your entire load-path when checking files.

When you edit user-init-file or files inside user-emacs-directory, Flycheck automatically adds ELPA packages to load-path, though.