Skip to main content

resolve_powershell_profile_path

Function resolve_powershell_profile_path 

Source
pub fn resolve_powershell_profile_path(home: &Path) -> PathBuf
Expand description

Resolve the active current-user PowerShell profile path.

On Windows the profile lives under the Documents known folder, which OneDrive folder backup (enabled by default on most installs) routinely redirects to e.g. …\OneDrive\Documents\PowerShell\…. A hardcoded ~\Documents therefore misses the real $PROFILE, so proxy enable / shell-hook install silently write to a file PowerShell never reads and the proxy receives no traffic (#558). We ask PowerShell itself for $PROFILE.CurrentUserCurrentHost — authoritative under any folder redirection — preferring pwsh (7+) then Windows PowerShell, and fall back to powershell_profile_path only when no PowerShell host can be launched (in which case the profile is moot anyway).

Non-Windows hosts keep the static ~/.config/powershell path (never ~/Documents, #356) and never spawn a process.