Subject: Re: bug#48452: 28.0.50; flymake for elisp does not respect `load-path`

From: João Távora <[email-masked]>
Date: Thu, 14 Jul 2022 21:29:32 +0100

Lars Ingebrigtsen <[email-masked]> writes:

> Max Brieiev <[email-masked]> writes:
>
>> I think this issue can not be reproduced with emacs -Q, because in this
>> case Elpa packages are not added to load-path. With emacs -Q, flymake
>> will rightfully complain "No such file or directory", when you `(require
>> 'any-elpa-package)`
>
> OK; so a way to reproduce this is to say (with "emacs -Q"):
>
> M-: (push (expand-file-name "~/.emacs.d/elpa/compat-28.1.1.1/") load-path)
> M-x flymake-mode
>
> and then notice that there's a warning on
>
> (require 'subr-x)
> (require 'compat)
>
> even though it can be required fine.
>
> I've added João to the CCs; perhaps he has some comments.

I think elisp-flymake-byte-compile-load-path is relevant here.

   elisp-flymake-byte-compile-load-path is a variable defined in `elisp-mode.el'.
    
   Its value is ("./")
    
   Like `load-path' but used by `elisp-flymake-byte-compile'.
   The default value contains just "./" which includes the default
   directory of the buffer being compiled, and nothing else.
    
     This variable is safe as a file local variable if its value
     satisfies the predicate which is a byte-compiled expression.

I don't usually develop packages in ~/.emacs.d/elpa, in fact developing
packages there is kind of questionable IMHO, as they are normally not
git checkouts.  This is, AFAIK, straight.el's main raison d'etre,
although I don't use that either.

But it could make sense to add ~/.emacs.d/elpa/* to the variable, if the
package you're developing somewhere else has a dependency on other Elpa
packages.

Although it's a safety hazard I guess (don't forget that the
elisp-flymake-byte-compile backend runs compile-time code!).  Or maybe
add a `package-initialize` call in the Emacs -Q that
elisp-flymake-byte-compile runs.  But that'll probably slow checking
down a bit, so i'd like to see some timings for the slowdown
before&after.

Or maybe, Max, you can just set this variable it in your file-local
variables or the dir-locals.el of the package you're developing.

João