Subject: Re: bug#20008: 24.4; Eshell eshell/which uses eshell-path-env but error with (getenv "PATH"), and these 2 sometimes get out of sync (not remote directory)

From: Stefan Kangas <[email-masked]>
Date: Sun, 01 Dec 2019 09:07:21 +0100

found 20008 27.0.50
tags 20008 + confirmed
thanks

Hua Wei <[email-masked]> writes:

> M-x eshell
> switch to other buffer 
> use (setenv "PATH"  "some path") to set new PATH env var
> enter eshell with C-u 2 eshell   (there is already one eshell buffer running)
>   a new eshell buffer opens
> type command "which <new cmd under new path>"
> output   "not found   in 'path'"  (in this message, the 'path' is from (getenv "PATH"))
>   this is confusing, because the function uses 'eshell-path-env' for search and use (getenv "PATH") for error messaging 
> the bug:
> eshell-path-env gets out of sync with (getenv "PATH")

I can reproduce this bug on Emacs 27.1 using the following recipe:

0. emacs -Q
1. M-x eshell
2. Enter commands in eshell:

   mkdir /tmp/foobin
   cp /bin/true /tmp/foobin/foobar
   setenv PATH /tmp/foobin
   foobar

Here is a transcript:

    Welcome to the Emacs shell
    
    ~ $ mkdir /tmp/foobin
    ~ $ cp /bin/true /tmp/foobin/foobar
    ~ $ setenv PATH /tmp/foobin
    /tmp/foobin
    ~ $ foobar
    foobar: command not found

Best regards,
Stefan Kangas