Subject: Re: bug#33255: 27.0.50; expand-file-name: default directory expanded twice if relative

From: Noam Postavsky <[email-masked]>
Date: Sun, 04 Nov 2018 07:27:29 -0500

immerrr again <[email-masked]> writes:

> I have recently tried to play with a clean .emacs.d directory by setting
> HOME=clean/home/dir, but faced an error coming from deep inside
> package-install. The error boils down to the fact that
> `expand-file-name' for some reason doubles the `default-directory'
> prefix when it is relative:
[...]
> I couldn't find any requirement for DEFAULT-DIRECTORY parameter or
> `default-directory' variable to be absolute, so I would assume this is a
> bug in expand-file-name.

(elisp) File Name Expansion says:

 -- Variable: default-directory
     The value of this buffer-local variable is the default directory
     for the current buffer.  It should be an absolute directory name;
     it may start with `~'.[...]

And expand-file-name is supposed to expand file names relative to
default-directory, so if default-directory is itself relative I don't
see how it could possibly work.  So we should just mention the
absoluteness requirement in the docstring as well.

I think it would make sense for Emacs to expand HOME against the current
directory when it starts up, if HOME is relative.  That would let your
motivating example succeed without error.