@@ -3,7 +3,6 @@ package cache
33import (
44 "hash/fnv"
55 "os"
6- "sync"
76
87 "github.com/jandedobbeleer/oh-my-posh/src/maps"
98)
@@ -14,15 +13,19 @@ const commandPathKeyPrefix = "command_path_"
1413
1514// pathEnvHash returns an FNV-1a hash of the environment that determines how
1615// exec.LookPath resolves a command: PATH, plus PATHEXT on Windows (unset and
17- // therefore a no-op elsewhere). It's computed once per process -- the
18- // environment can't change under us in a short-lived prompt render.
19- var pathEnvHash = sync .OnceValue (func () uint64 {
16+ // therefore a no-op elsewhere). Computed on every call, NOT memoized: the
17+ // serve daemon lives across prompts and applies each request's env overlay
18+ // (PATH included) in-process, so a per-process hash would keep matching
19+ // entries persisted under an earlier PATH and pin e.g. `python` to a
20+ // previous virtual environment's interpreter for the daemon's lifetime -
21+ // the old binary still exists, so the os.Stat revalidation never catches it.
22+ func pathEnvHash () uint64 {
2023 h := fnv .New64a ()
2124 _ , _ = h .Write ([]byte (os .Getenv ("PATH" )))
2225 _ , _ = h .Write ([]byte {0 })
2326 _ , _ = h .Write ([]byte (os .Getenv ("PATHEXT" )))
2427 return h .Sum64 ()
25- })
28+ }
2629
2730// Command lookup TTLs for the session-persisted layer (L2). The in-memory
2831// layer (L1, Commands below) is unbounded for the lifetime of the process,
0 commit comments