Subject: bug#58073: 29.0.50; Uninstalled emacs sends startup messages to stderr

From: Eli Zaretskii <[email-masked]>
Date: Mon, 03 Oct 2022 22:01:48 +0300

> From: Jonas Bernoulli <[email-masked]>
> Cc: [email-masked]
> Date: Mon, 03 Oct 2022 20:51:05 +0200
> 
> Before I switched away from Gdm3, I had to use a wrapper script, but as
> we found out that does not actually work.  For some reason that ends up
> using the elisp libraries from where "make install" put them.  Or if
> that has never been run, then emacs fails because it cannot find the
> libraries where it (IMO falsely) expects to find them.  The same happens
> when using a shell alias.
> 
> The question now is whether *you* consider this a bug worth fixing.
> I would say it is, but I won't insist on it.

It may or may not be a bug; it could be a feature.

When Emacs starts up it needs to decide where to find the pdumper file
and where to find the *.eln files.  It does that by looking at the
directory where its executable lives, if it can determine that via
argv[0].  But symlinks could trick that, and if you invoke Emacs
through wrapper scripts or aliases, that could make the above
impossible, because there are no valid leading directories in argv[0].
In that case, the startup code uses Plan B: it goes by its configured
installation location.  And since you have the same Emacs both
installed and uninstalled, you get what you see.  Or something like
that: to see what really happens, you need to step with a debugger
through the code of the load_pdump function, see where it finds the
pdumper file, and where it decides to look for *.eln (by constructing
the name in emacs_executable, whose leading directory is then used in
dump_do_dump_relocation under 'case RELOC_NATIVE_COMP_UNIT').