Subject: bug#76888: 31.0.50; start-process: Spawning child process: Invalid argument

From: Eli Zaretskii <[email-masked]>
Date: Sun, 16 Mar 2025 10:21:13 +0200

> Cc: [email-masked]
> Date: Sat, 15 Mar 2025 13:48:10 +0200
> From: Eli Zaretskii <[email-masked]>

Trying this recipe, I have some questions and observations.

> > From: Richard Copley <[email-masked]>
> > Date: Sun, 9 Mar 2025 12:37:56 +0000
> > 
> > When the "*Async Shell Command*" buffer is re-used, its
> > connection-local variable 'shell-file-name' is set permanently instead
> > of temporarily, and if the value is inappropriate, an error ensues.

I'm not sure this is relevant, see below.  Or if it _is_ relevant, I
don't think I understand why the value of shell-file-name in the
"*Async Shell Command*" buffer matters.

> > Recipe from 'emacs -Q', on Windows:
> > 
> > Visit a remote file on a Linux system using tramp. (You will need to
> > substitute an appropriate remote file name here.)
> > 
> > [C-x C-f] /plink:xxx:/ [RET]

This shows the remote file on display.

> > Execute an asynchronous shell command.
> > 
> > [M-&] echo [RET]

This command should run on the remote host, because the
default-directory is remote, due to the current-buffer visiting a
remote file, per the above "C-x C-f" command.

Is that what you see?  Does the "echo" command run on the remote host?

> > NOTE: (with-current-buffer "*Async Shell Command*" shell-file-name)
> > returns the path to "cmdproxy.exe" as expected.
> > 
> > Execute an asynchronous shell command again.
> > 
> > [M-&] echo [RET]
> > 
> > NOTE: (with-current-buffer "*Async Shell Command*" shell-file-name)
> > now returns "/bin/sh".
> > 
> > Visit a local file.
> > 
> > [C-x C-f C-a C-k] C:/ [RET]

Now the local file is shown in the selected window, and the current
buffer visits that file, so its default-directory is local.

> > Execute an async shell command.
> > 
> > [M-&] echo [RET]

This command should run locally, because default-directory is local.
Is that what you see?

> > An error is signalled, with the message "start-process: Spawning child
> > process: Invalid argument". (Note, the invalid argument is the
> > executable name, "/bin/sh").

In my case, the error message dosn't pop up each time, but I do see it
from time to time.

Michael, does Tramp reuse the value of shell-file-name between shell
commands, and if so, how does it know whether to reuse or not?