unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Max Brieiev <max.brieiev@gmail.com>,
	Lars Ingebrigtsen <larsi@gnus.org>,
	48452@debbugs.gnu.org
Subject: bug#48452: 28.0.50; flymake for elisp does not respect `load-path`
Date: Sat, 23 Jul 2022 18:45:04 +0100	[thread overview]
Message-ID: <87h737n2ov.fsf@gmail.com> (raw)
In-Reply-To: <jwv8roj7w9s.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 23 Jul 2022 10:26:45 -0400")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> At some point in the past, Stefan was working on a "sandboxed" Emacs
>> that could, in theory, pave the way for automatically enabled Elisp
>> Flymake, but I haven't heard of that effort lately.
>
> I need to get back to that indeed :-)
>
>>> It seems to me that there's two useful values for load-path in the
>>> Flymake backend: Either just the standard load-path (so that you
>>> actually get the same results as when doing a batch byte-compile) or the
>>> current running load-path (so that you get the same results as when you
>>> `require' the file from your .emacs, say).  Altering the load-path to
>>> also include the ELPA directories doesn't really help much, because
>>> people have all kinds of code that's not in ELPA (but is in their
>>> load-path).
>
> AFAIC, it's not just `load-path`: the set of autoloaded functions (and
> a few other similar things) is also relevant.

I presume those relevant things are setup by package-initialize, right?
My proposed patch uses that.

>> I think we have to ask ourselves: what is Flymake used for?  The most
>> useful answers will come from the people who actually use it, though
>> potential uses are also interesting.
>
> I don't think we can hope to make flymake-elisp work correctly in all
> existing cases, because there are conflicting requirements there.
>
> So, we should take it for granted that some use-cases will be considered
> as "unsupported", and the important thing is to figure out what behavior
> to provide such that all(?) use-cases can be adapted (and such that the
> behavior is sane enough to be described, understandable, and
> predictable).
>
>> Having './' in the default load-path for elisp-flymake-byte-compile is
>> fundamental for the accuracy of this prediction.  Why?  Because the
>> clients of my packages -- regardless if they use package.el,
>> straight.el, etc or just simply using a git checkout -- will always have
>> the the files I have in some directory in some other directory in their
>> machines, and _that_ directory will be in the load-path.
>
> BTW, while the GNUmakefile of `elpa-admin` also adds `.` to the
> `load-path`, there are cases where this is harmful.

I don't dispute that, but in my experience (and as far as I can see) it
is _not_ functionally harmful to have ./ in the
elisp-flymake-byte-compile-load-path for the use case that I described:
developing package.el packages that can be distributed and installed
through a number of ways.

But is it potentially "dangerous/disastrous"?  I don't think so either,
but I haven't a clear picture of the disaster scenario.  Lars mentioned
"editing files in /tmp".

Maybe Lars is worried about some user e.g. having /tmp/bad.el and
opening some /tmp/good.el and slowly typing in

   (require 'badminton)

By the time (require 'bad) is in the buffer, disaster strikes.  But this
disaster could just as well happen by simply visiting /tmp/bad.el to see
what's in it.  Except that malicious files don't advertise themselves
like that in their file names...

Or maybe -- again, I'm just guessing -- the danger is that that bad.el
is disguised under /tmp/pcase.el and /tmp/good.el has a perfectly
legitimate.

   (require 'pcase)

Simply visitng /tmp/good.el with Flymake on would lead to disaster.  If
that's the case, it's as easy as applying this patch

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 0c4a9bfdbe..01c0679c76 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -2144,7 +2144,7 @@ elisp-flymake-byte-compile
                    "-Q"
                    "--batch"
                    ;; "--eval" "(setq load-prefer-newer t)" ; for testing
-                   ,@(mapcan (lambda (path) (list "-L" path))
+                   ,@(mapcan (lambda (path) (list "-L" (format ":%s" path)))
                              elisp-flymake-byte-compile-load-path)
                    "-f" "elisp-flymake--batch-compile-for-flymake"
                    ,temp-file)

João





  reply	other threads:[~2022-07-23 17:45 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-15 20:46 bug#48452: 28.0.50; flymake for elisp does not respect `load-path` Max Brieiev
2022-07-13 11:47 ` Lars Ingebrigtsen
2022-07-13 13:47   ` Max Brieiev
2022-07-13 13:57     ` Lars Ingebrigtsen
2022-07-13 16:24       ` Max Brieiev
2022-07-14 17:15         ` Lars Ingebrigtsen
2022-07-14 20:29           ` João Távora
2022-07-15  9:46             ` Lars Ingebrigtsen
2022-07-15 10:03               ` João Távora
2022-07-16 10:12                 ` Lars Ingebrigtsen
2022-07-18 19:17                   ` João Távora
2022-07-22 19:52                     ` Lars Ingebrigtsen
2022-07-22 21:09                       ` João Távora
2022-07-22 21:12                         ` Lars Ingebrigtsen
2022-07-22 21:46                           ` João Távora
2022-07-23  5:50                             ` Lars Ingebrigtsen
2022-07-23  9:24                               ` João Távora
2022-07-23 14:26                                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-23 17:45                                   ` João Távora [this message]
2022-07-23 17:55                                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-24  9:18                                     ` Lars Ingebrigtsen
2022-07-24  9:57                                       ` João Távora
2022-07-23 15:05                                 ` Max Brieiev
2022-07-23 17:16                                   ` João Távora
2022-07-15 11:53             ` Max Brieiev
2022-07-14  9:22       ` Max Brieiev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h737n2ov.fsf@gmail.com \
    --to=joaotavora@gmail.com \
    --cc=48452@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=max.brieiev@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).