Apologies for the confusion and for taking up your time with this—it was my own mistake. I really appreciate your help.
After all the investigation above, I finally discovered the true culprit: a project‑root .env file that I had added for other tooling (e.g. to set JAVA_HOME for a Processing‑like Python library py5). That file contained something like:
# .env at the workspace root
JAVA_HOME=C:\Some\Java\Path
PATH=$JAVA_HOME$;$PATH
.env and appends it to the existing environment, so your real PATH (and PROGRAMFILES, LOCALAPPDATA, etc.) remain intact—PowerShell and CMD subprocesses work fine..env and override the entire process environment. As a result:
PATH becomes exactly C:\Some\Java\Path\bin;$PATH (no Windows system paths)powershell.exe can’t be found (or finds no inherited variables like PROGRAMFILES)$env:… lookups return empty stringsRemove or adjust the .env so it doesn’t clobber your entire PATH. For example, change it to extend rather than replace(change $VAR to %VAR%):
# .env — extend the existing PATH instead of overwriting it
JAVA_HOME=C:\Some\Java\Path
PATH=%JAVA_HOME%;%PATH%
After making one of these changes, PowerShell subprocesses under debugpy will once again inherit the full environment, and $env:PROGRAMFILES, $env:LOCALAPPDATA, etc. will be populated as expected.