Subject: bug#74550: eshell cannot set the environment variable PATH on Windows

From: Jim Porter <[email-masked]>
Date: Wed, 27 Nov 2024 10:52:47 -0800

On 11/27/2024 9:15 AM, Siyuan Chen wrote:
> It works, thanks.
> 
> However, this seems to be a global setting only. Is there any equivalent 
> of with-environment-variables for exec-path?

Not exactly. However, you can use setq-local or eshell/addpath:

   (defun shell1 ()
     (interactive)
     (let ((current-prefix-arg 4))
       (call-interactively 'shell)
       (setq-local exec-path (cons "C:/foo" exec-path))
       ;; or ...
       (eshell/addpath "-b" "C:/foo")))

That's probably the best way to do it for now. I think it's probably 
reasonable for Eshell to work correctly when you've let-bound 
'exec-path' like in your examples, but I'll have to think about the best 
way to do it.