Skip to content

Commit a9f0e0a

Browse files
committed
Give better uninstall error feedback
1 parent aadddd4 commit a9f0e0a

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

ChocolateyPackage/tools/Install-Module.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ param(
55
[String] $ModuleName
66
)
77

8+
$ErrorActionPreference = "Stop"
9+
810
if (!(Test-Path -PathType Container $PathToModuleFiles)) {
911
Write-Error "$PathToModuleFiles not found or is not a directory. Nothing to install."
1012
exit

ChocolateyPackage/tools/Remove-Module.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ param(
33
[String] $ModuleName
44
)
55

6+
$ErrorActionPreference = "Stop"
7+
8+
69
$moduleRoot = "$($env:CommonProgramW6432)\Modules\"
710
$dir = "$moduleRoot\$ModuleName\"
811

ChocolateyPackage/tools/chocolateyuninstall.ps1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ try {
66

77
Write-ChocolateySuccess $packageName
88
} catch {
9-
Write-ChocolateyFailure $packageName $($_.Exception.Message)
9+
$message = @"
10+
Uhoh. Looks like $packageName doesn't want to uninstall! But don't worry there is probably a good explanation.
11+
12+
It is highly likely that you have an instance of PowerShell running with $packageName loaded.
13+
14+
You should probably try closing all instances of PowerShell and rerunning this uninstall from cmd.exe.
15+
"@
16+
17+
Write-Host "==============================================="
18+
Write-Host $message
19+
Write-Host "==============================================="
1020
throw
1121
}

0 commit comments

Comments
 (0)