Subject: Re: bug#55743: 28.1.50; No directory error in comp-run-async-workers

From: Juri Linkov <[email-masked]>
Date: Tue, 31 May 2022 22:49:37 +0300

>> So here are two problems: why completion sets default-directory to non-existent dir,
>
> That's the real problem.

Oh, I see, it's a known problem.  In completion-setup-function:

         (base-dir
          ;; FIXME: This is a bad hack.  We try to set the default-directory
          ;; in the *Completions* buffer so that the relative file names
          ;; displayed there can be treated as valid file names, independently
          ;; from the completion context.  But this suffers from many problems:
          ;; - It's not clear when the completions are file names.  With some
          ;;   completion tables (e.g. bzr revision specs), the listed
          ;;   completions can mix file names and other things.
          ;; - It doesn't pay attention to possible quoting.
          ;; - With fancy completion styles, the code below will not always
          ;;   find the right base directory.
          (if minibuffer-completing-file-name
              (file-name-as-directory
               (expand-file-name
                (buffer-substring (minibuffer-prompt-end) (point)))))))
      ...
      (if base-dir (setq default-directory base-dir))

>> and why comp-run-async-workers tries to run a process in such arbitrary invalid dirs.
>
> It is not comp-run-async-workers that does it, it's the low-level
> infrastructure in subroutines of make-process: it makes sure the
> directory in which the process will run is valid, and if it isn't
> signals an error.

Shouldn't native compilation run in the directory where the emacs
source files are located instead of running in the default directory
of an arbitrary buffer that might be invalid?