-
Notifications
You must be signed in to change notification settings - Fork 7.2k
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
Use the same temp personal module path when env 'HOME' not defined #13239
Conversation
I wonder if it's possible to test this by unsetting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this! I don't think we need tests for this change, and as long as current tests pass I feel we are good.
@PoshChan please remind me in 23 hours |
string envHome = System.Environment.GetEnvironmentVariable(CommonEnvVariableNames.Home); | ||
if (envHome == null) | ||
{ | ||
envHome = GetTemporaryDirectory(); | ||
s_tempHomeDir ??= GetTemporaryDirectory(); | ||
envHome = s_tempHomeDir; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You assume that HOME could be defined on the fly (and preserve current behavior) but we could already put some files in previous folder :-(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry that I missed this comment. I think it would be very unlikely that the HOME
env var changes it value after it's declared, so I'm not too worry about this.
@rjmholt, this is the reminder you requested 23 hours ago |
Will be this backported to 7.0? |
|
Good question. Maybe it's worth backporting, given the fix is so simple. |
🎉 Handy links: |
🎉 Handy links: |
PR Summary
Fix #13189
When the env variable
HOME
is not defined, every Runspace startup on Unix platforms will try creating a folder in the form of/tmp/<new-guid>/.local/share/powershell/Modules
as the personal user module path. That means LOTs of such folders get created whenForeach-Object -Parallel
is dealing with a lot of inputs. In that situation, it may not be surprising to see strange failures like theDirectoryNotFoundException
reported in the issue.This PR adds a static field to cache the temporary personal user module path, so all Runspace's will use the same temp directory path in case
HOME
env variable is not defined.PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.