From 837782c1d7507431d4ce39e37a4b978f9942f3a2 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Mon, 23 Dec 2024 22:08:07 -0500 Subject: [PATCH] Now creating a pathfixer.ps1 that will try to fix the path after the installs. --- base.ps1 | 13 ++++--------- pathfixer.ps1 | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 pathfixer.ps1 diff --git a/base.ps1 b/base.ps1 index 1cade2e..0297fe1 100644 --- a/base.ps1 +++ b/base.ps1 @@ -275,19 +275,14 @@ if($env:PATH.contains($winlibsPath)) { } $gitPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$env:APPDATA\..\Local\Programs\Git\cmd") - +Write-Warning "============= GIT CHECK ===========" if($env:PATH.contains($gitPath)) { - Write-Warning "!! Looks like your git installed correctly, but if it fails to run then uninstall it with 'winget remove git.git' then install it again with 'winget install git.git'" + Write-Host "!! Looks like your git installed correctly, but if it fails to run then uninstall it with 'winget remove git.git' then install it again with 'winget install git.git'" } else { Write-Warning "!! Git.Git did not add itself to the Path. The directory $gitPath is missing so I'll add it now." $newPath = $env:PATH + ";$gitPath" [Environment]::SetEnvironmentVariable("Path", $newPath, "User") - if($env:PATH.contains($gitPath)) { - Write-Warning "?? Great, git is in the path so if it is gone after this then something is going on." - } else { - Write-Warning "!!!!!!!!!!!!!!!!!!!!! Despite manually forcing the git $gitPath into the path it is _still_ not there." - Write-Warning "You'll have to manually install git later with: winget install git.git." - winget remove git.git - } + Write-Host "!!!!!!!! You should get the pathfixer.ps1 script to attempt to force $gitPath into the user PATH." + Write-Host "You do this the same way you got this script, just replace base.ps1 with pathfixer.ps1" } diff --git a/pathfixer.ps1 b/pathfixer.ps1 new file mode 100644 index 0000000..fee507c --- /dev/null +++ b/pathfixer.ps1 @@ -0,0 +1,30 @@ +Write-Host "======= winlibs configuration =====" +$winlibsPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$env:APPDATA\..\Local\Programs\WinLibs") + +if($env:PATH.contains($winlibsPath)) { + Write-Warning "!! Detected $winLibsPath in your PATH. Will not update your PATH." + Write-Host "Looks like your WinLibs is working." +} else { + $newPath = $env:PATH + ";$winlibsPath\mingw64\bin" + [Environment]::SetEnvironmentVariable("Path", $newPath, "User") +} + +Write-Host "====== git path configuration ======" + +$gitPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$env:APPDATA\..\Local\Programs\Git\cmd") + +if($env:PATH.contains($gitPath)) { + Write-Warning "!! Detected $gitPath in your PATH. Will not update your PATH." + Write-Host "Looks like your git installed correctly, but if it fails to run then uninstall it with 'winget remove git.git' then install it again with 'winget install git.git'" +} else { + Write-Warning "!! Git.Git did not add itself to the Path. The directory $gitPath is missing so I'll add it now." + $newPath = $env:PATH + ";$gitPath" + [Environment]::SetEnvironmentVariable("Path", $newPath, "User") + + Write-Warning "!!!!!!!!!!! If git doesn't work after this you'll have to manually remove it and add it with:" + Write-Host "winget remove git.git" + Write-Host "winget install git.git" +} + +Write-Warning "================================" +Write-Warning "You should now close this terminal, start a new one, and run this script again to confirm your paths are set."