Skip to content

Commit 8500732

Browse files
Improve ClaudeCode install/uninstall fallback logic
Updated ClaudeCode installation and uninstallation commands to use the official shell installer on Linux and MacOS, and added logic to Install-AITool and Uninstall-AITool to check for winget availability on Windows, falling back to alternative methods if winget is not present. Bumped module version to 1.0.3.
1 parent 2a25174 commit 8500732

4 files changed

Lines changed: 31 additions & 5 deletions

File tree

aitools.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
RootModule = 'aitools.psm1'
1010

1111
# Version number of this module.
12-
ModuleVersion = '1.0.2'
12+
ModuleVersion = '1.0.3'
1313

1414
# ID used to uniquely identify this module
1515
GUID = 'c90f5001-c492-4fbe-8ab3-f03599951bd0'

aitools.psm1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ $script:ToolDefinitions = @{
5050
Command = 'claude'
5151
InstallCommands = @{
5252
Windows = 'winget install --id=Anthropic.ClaudeCode -e --accept-source-agreements --accept-package-agreements'
53-
Linux = 'npm install -g @anthropic-ai/claude-code'
54-
MacOS = 'npm install -g @anthropic-ai/claude-code'
53+
Linux = 'curl -fsSL https://claude.ai/install.sh | bash'
54+
MacOS = 'curl -fsSL https://claude.ai/install.sh | bash'
5555
}
5656
UninstallCommands = @{
5757
Windows = 'winget uninstall --id=Anthropic.ClaudeCode -e --accept-source-agreements --accept-package-agreements'
58-
Linux = 'npm uninstall -g @anthropic-ai/claude-code'
59-
MacOS = 'npm uninstall -g @anthropic-ai/claude-code'
58+
Linux = 'claude uninstall'
59+
MacOS = 'claude uninstall'
6060
}
6161
TestCommand = 'claude --version'
6262
InitCommand = 'claude setup-token'

public/Install-AITool.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,19 @@ function Install-AITool {
120120
$installCmd = @($installCmd)
121121
}
122122

123+
# For ClaudeCode on Windows with winget, check if winget is available and fallback to PowerShell installer if not
124+
if ($currentToolName -eq 'ClaudeCode' -and $os -eq 'Windows' -and $installCmd[0] -match '^winget') {
125+
Write-Progress -Activity "Installing $currentToolName" -Status "Checking for winget availability" -PercentComplete 18
126+
Write-PSFMessage -Level Verbose -Message "Checking if winget is available..."
127+
if (-not (Test-Command -Command 'winget')) {
128+
Write-PSFMessage -Level Warning -Message "winget is not available. Falling back to PowerShell installer..."
129+
$installCmd = @('irm https://claude.ai/install.ps1 | iex')
130+
Write-PSFMessage -Level Verbose -Message "Using fallback command: $($installCmd[0])"
131+
} else {
132+
Write-PSFMessage -Level Verbose -Message "winget is available, proceeding with winget installation"
133+
}
134+
}
135+
123136
# Check for Node.js prerequisite if using npm installation
124137
if ($installCmd[0] -match '^npm install') {
125138
Write-Progress -Activity "Installing $currentToolName" -Status "Checking prerequisites" -PercentComplete 20

public/Uninstall-AITool.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,19 @@ function Uninstall-AITool {
100100
return
101101
}
102102

103+
# For ClaudeCode on Windows with winget, check if winget is available and fallback to native uninstaller if not
104+
if ($Name -eq 'ClaudeCode' -and $os -eq 'Windows' -and $uninstallCmd -match '^winget') {
105+
Write-Progress -Activity "Uninstalling $Name" -Status "Checking for winget availability" -PercentComplete 20
106+
Write-PSFMessage -Level Verbose -Message "Checking if winget is available..."
107+
if (-not (Test-Command -Command 'winget')) {
108+
Write-PSFMessage -Level Warning -Message "winget is not available. Falling back to native uninstaller..."
109+
$uninstallCmd = 'claude uninstall'
110+
Write-PSFMessage -Level Verbose -Message "Using fallback command: $uninstallCmd"
111+
} else {
112+
Write-PSFMessage -Level Verbose -Message "winget is available, proceeding with winget uninstallation"
113+
}
114+
}
115+
103116
# Confirm unless Force is specified
104117
if (-not $Force -and -not $PSCmdlet.ShouldProcess($Name, "Uninstall AI tool")) {
105118
Write-Progress -Activity "Uninstalling $Name" -Completed

0 commit comments

Comments
 (0)