Created
November 13, 2025 21:52
-
-
Save jcefoli/638ae844282de93b8e7ed58f91613299 to your computer and use it in GitHub Desktop.
Fix pyenv-win variables. Their instructions to install on windows were shit and I broke it out of the box, so this fixed it
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
| # Check current PATH | |
| Write-Host "Current PATH:" $env:PATH | |
| # Split PATH into entries | |
| $pathEntries = $env:PATH -split ';' | |
| # Filter out invalid entries (empty or whitespace) | |
| $cleanEntries = $pathEntries | Where-Object { $_ -and ($_ -match '\S') } | |
| # Ensure pyenv-win paths are first | |
| $pyenvBin = "$env:USERPROFILE\.pyenv\pyenv-win\bin" | |
| $pyenvShims = "$env:USERPROFILE\.pyenv\pyenv-win\shims" | |
| # Remove duplicates | |
| $cleanEntries = $cleanEntries | Where-Object { $_ -ne $pyenvBin -and $_ -ne $pyenvShims } | |
| # Rebuild PATH with pyenv first | |
| $newPath = "$pyenvBin;$pyenvShims;" + ($cleanEntries -join ';') | |
| # Apply to user environment | |
| [System.Environment]::SetEnvironmentVariable("PATH", $newPath, "User") | |
| Write-Host "Updated PATH:" $newPath | |
| Write-Host "Restart PowerShell and run: pyenv version" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment