From ea9754504e264ded82cca786a425d19c0dfe3df2 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Wed, 22 Jul 2020 11:59:06 -0700 Subject: [PATCH] Use the same temp personal module path when env 'HOME' not defined --- src/System.Management.Automation/CoreCLR/CorePsPlatform.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs b/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs index c6ac57070cb..4e572586c98 100644 --- a/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs +++ b/src/System.Management.Automation/CoreCLR/CorePsPlatform.cs @@ -239,6 +239,8 @@ public enum XDG_Type DEFAULT } + private static string s_tempHomeDir = null; + /// /// Function for choosing directory location of PowerShell for profile loading. /// @@ -252,7 +254,8 @@ public static string SelectProductNameForDirectory(Platform.XDG_Type dirpath) string envHome = System.Environment.GetEnvironmentVariable(CommonEnvVariableNames.Home); if (envHome == null) { - envHome = GetTemporaryDirectory(); + s_tempHomeDir ??= GetTemporaryDirectory(); + envHome = s_tempHomeDir; } string xdgConfigHomeDefault = Path.Combine(envHome, ".config", "powershell");