Revert "[release/v7.5.7] Fix checks for local user config file paths"#27476
Merged
adityapatwardhan merged 1 commit intoMay 19, 2026
release/v7.5.7PowerShell/PowerShell:release/v7.5.7from
revert-27459-backport/release/v7.5.7/26269-c7ee0d294PowerShell/PowerShell:revert-27459-backport/release/v7.5.7/26269-c7ee0d294Copy head branch name to clipboard
Merged
Revert "[release/v7.5.7] Fix checks for local user config file paths"#27476adityapatwardhan merged 1 commit intorelease/v7.5.7PowerShell/PowerShell:release/v7.5.7from revert-27459-backport/release/v7.5.7/26269-c7ee0d294PowerShell/PowerShell:revert-27459-backport/release/v7.5.7/26269-c7ee0d294Copy head branch name to clipboard
adityapatwardhan merged 1 commit into
release/v7.5.7PowerShell/PowerShell:release/v7.5.7from
revert-27459-backport/release/v7.5.7/26269-c7ee0d294PowerShell/PowerShell:revert-27459-backport/release/v7.5.7/26269-c7ee0d294Copy head branch name to clipboard
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reverts the earlier change that added extra validation around deriving per-user config/cache paths, restoring prior behavior in several core engine and host components (telemetry, update notifications, module analysis cache, profile/config path derivation, and ~ expansion in PATH processing).
Changes:
- Removes “derive from cache” gating and several
string.IsNullOrEmpty(...)guards, allowing code paths to proceed even when cache/config directories can’t be resolved. - Reverts Windows folder derivation behavior by removing
SpecialFolderOption.DoNotVerifyusage and helper methods inCorePsPlatform. - Reverts
~/~/...PATH expansion to use defaultEnvironment.GetFolderPath(...)semantics.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/System.Management.Automation/utils/Telemetry.cs | Stops gating telemetry enablement on successfully deriving a cache path. |
| src/System.Management.Automation/engine/PSConfiguration.cs | Removes empty-checks when deriving the per-user config file path and reading from it. |
| src/System.Management.Automation/engine/Modules/AnalysisCache.cs | Derives module analysis cache file location directly from Platform.CacheDirectory. |
| src/System.Management.Automation/engine/hostifaces/MshHostUserInterface.cs | Removes an early return when transcript base directory is empty. |
| src/System.Management.Automation/engine/hostifaces/HostUtilities.cs | Changes when/where empty base-path checks apply for profile paths. |
| src/System.Management.Automation/engine/CommandDiscovery.cs | Reverts ~ expansion to use Environment.GetFolderPath(UserProfile) without DoNotVerify. |
| src/System.Management.Automation/CoreCLR/CorePsPlatform.cs | Reverts cache/config directory derivation and removes TryDeriveFromCache + safe folder derivation helpers. |
| src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs | Removes cache-derivation gating for enabling update notifications; derives cache directory directly. |
| src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs | Adjusts profile optimization directory creation behavior for cache directory. |
Comment on lines
+211
to
216
| if (string.IsNullOrEmpty(basePath)) | ||
| { | ||
| return string.Empty; | ||
| } | ||
| } | ||
|
|
Comment on lines
89
to
93
| // Note: This directory may or may not exist depending upon the execution scenario. | ||
| // Writes will attempt to create the directory if it does not already exist. | ||
| perUserConfigDirectory = Platform.ConfigDirectory; | ||
| if (!string.IsNullOrEmpty(perUserConfigDirectory)) | ||
| { | ||
| perUserConfigFile = Path.Combine(perUserConfigDirectory, ConfigFileName); | ||
| } | ||
| perUserConfigFile = Path.Combine(perUserConfigDirectory, ConfigFileName); | ||
|
|
Comment on lines
1219
to
1222
| if (tempDir.EqualsOrdinalIgnoreCase("~")) | ||
| { | ||
| tempDir = Environment.GetFolderPath( | ||
| Environment.SpecialFolder.UserProfile, | ||
| Environment.SpecialFolderOption.DoNotVerify); | ||
| tempDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); | ||
| } |
Comment on lines
1223
to
1226
| else if (tempDir.StartsWith("~" + Path.DirectorySeparatorChar)) | ||
| { | ||
| tempDir = Environment.GetFolderPath( | ||
| Environment.SpecialFolder.UserProfile, | ||
| Environment.SpecialFolderOption.DoNotVerify) | ||
| + Path.DirectorySeparatorChar | ||
| + tempDir.Substring(2); | ||
| tempDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + Path.DirectorySeparatorChar + tempDir.Substring(2); | ||
| } |
Comment on lines
+170
to
172
| internal static readonly string CacheDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Microsoft\PowerShell"; | ||
| internal static readonly string ConfigDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\PowerShell"; | ||
|
|
| }; | ||
| #else | ||
| return Environment.GetFolderPath(folder, Environment.SpecialFolderOption.DoNotVerify); | ||
| return Environment.GetFolderPath(folder); |
Comment on lines
+63
to
+68
| CanNotifyUpdates = s_notificationType != NotificationType.Off; | ||
|
|
||
| if (CanNotifyUpdates) | ||
| { | ||
| s_enumOptions = new EnumerationOptions(); | ||
| s_cacheDirectory = Path.Combine(Platform.CacheDirectory, PSVersionInfo.GitCommitId); |
SeeminglyScience
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reverts #27459