Use the same temp personal module path when env 'HOME' not defined by daxian-dbw · Pull Request #13239 · PowerShell/PowerShell
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 when Foreach-Object -Parallel is dealing with a lot of inputs. In that situation, it may not be surprising to see strange failures like the DirectoryNotFoundException 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
- PR has a meaningful title
- Use the present tense and imperative mood when describing your changes
- Summarized changes
- Make sure all
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header - This PR is ready to merge and is not Work in Progress.
- If the PR is work in progress, please add the prefix
WIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.
- If the PR is work in progress, please add the prefix
- Breaking changes
- None
- OR
- Experimental feature(s) needed
- Experimental feature name(s):
- User-facing changes
- Not Applicable
- OR
- Documentation needed
- Issue filed:
- Testing - New and feature
- N/A or can only be tested interactively
- OR
- Make sure you've added a new test if existing tests do not effectively test the code changed
- Tooling
- I have considered the user experience from a tooling perspective and don't believe tooling will be impacted.
- OR
- I have considered the user experience from a tooling perspective and enumerated concerns in the summary. This may include:
- Impact on PowerShell Editor Services which is used in the PowerShell extension for VSCode (which runs in a different PS Host).
- Impact on Completions (both in the console and in editors) - one of PowerShell's most powerful features.
- Impact on PSScriptAnalyzer (which provides linting & formatting in the editor extensions).
- Impact on EditorSyntax (which provides syntax highlighting with in VSCode, GitHub, and many other editors).