-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using Get-AppxPackage
when SYSTEMDRIVE
env var is not set creates a (literal) %SystemDrive%/…
directory
#23807
Comments
Maybe that's also something more general. In particular I've just noticed that the same happens with |
Given that Get-AppxPackage comes from a module in 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Appx' then it seems reasonable that it has expectations of a windows environment. As far as I can tell it is not part of the PowerShell Core project.
Fortunately, you have already identified the root cause. If you want to have a clean environment without any environment variables that Windows programs depend on, then don't run any Windows programs that depend on those environment variables. |
Well, still it's probably not good behaviour if the programs behave odd without any error, when crucial stuff is missing. |
You are absolutely right, I would not recommend removing standard windows environment variables that windows apps have a reasonable expectation of being correctly set in order to operate. |
PowerShell itself doesn't have a dependency on |
This issue has been marked as external and has not had any activity for 1 day. It has been be closed for housekeeping purposes. |
📣 Hey @philcerf, how did we do? We would love to hear your feedback with the link below! 🗣️ 🔗 https://aka.ms/PSRepoFeedback |
Prerequisites
Steps to reproduce
Hey.
This is also seems to reach back to the days of
powershell.exe
but still happens with current 7.4 versions.I run some (POSIX) shell scripts from Cygwin, and for some Windows specific stuff they use PowerShell since there's no better way to get to the data.
One thing is, that – since in my shell scripts I sanitise (that is clear) most env vars – I have a function that searches for the executable path of a Windows Python installation.
That function supports "manual" installations, but also ones via the Microsoft Store, so I do something like:
to get the list of Python App Installation pathnames, sorted by version.
If using
pwsh.exe
on may need to add aImport-Module Appx -UseWindowsPowerShell
(because of the nasty #13138). I'm using Windows 10 (don't wanna throw away my still perfectly working hardware just to satisfy Win 11'snonrequirements ;-) ).Works in principle fine, but as I've mentioned earlier, my shell scripts basically clear their environment (except for a few things like
PATH
(which they overwrite however with a POSIX like path list O:-) )... and it turns out, that this causes the file tree:to be created, whenever I run
Get-AppxPackage
.Seems the culprit is that I have no
SYSTEMDRIVE
env var set in my (POSIX) shell script, and thus PowerShell probably doesn't get it either.One can (from Cygwin) easily test via:
%SystemDrive%
is created%SystemDrive%
is created.Expected behavior
Actual behavior
Spuriously creates a file tree at the working directory.
Error details
No response
Environment data
and
The text was updated successfully, but these errors were encountered: