Skip to content

Instantly share code, notes, and snippets.

@jcefoli
Created November 13, 2025 21:52
Show Gist options
  • Select an option

  • Save jcefoli/638ae844282de93b8e7ed58f91613299 to your computer and use it in GitHub Desktop.

Select an option

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
# 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