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?

5
  • 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? 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, 2015 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, 2015 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. Mar 24, 2015 at 3:16
  • 1
    Thank you both for helping to correct me -- I am always grateful to learn new aspects of Emacs.
    – lawlist
    Mar 24, 2015 at 3: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. Mar 24, 2015 at 14:32

1 Answer 1

14

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.

3
  • 1
    Is there a way to make flycheck add the elpa packages from any directory?
    – Malabarba
    Mar 24, 2015 at 19:08
  • 2
    @Malabarba flycheck-emacs-lisp-initialize-packages and flycheck-emacs-lisp-package-user-dir
    – user227
    Mar 24, 2015 at 19:24
  • 1
    set flycheck-emacs-lisp-load-path to inherit, and this is solved issue, many thanks! Mar 25, 2015 at 4:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.