Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/user_docs/getting-started/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ Install or upgrade the latest darwin KCL to /usr/local/bin
curl -fsSL https://kcl-lang.io/script/install-cli.sh | /bin/bash
```

Uninstall

```bash
curl -fsSL https://kcl-lang.io/script/uninstall-cli.sh | /bin/bash
```

#### Linux

Install or upgrade the latest linux KCL to /usr/local/bin
Expand All @@ -42,6 +48,12 @@ Install or upgrade the latest linux KCL to /usr/local/bin
wget -q https://kcl-lang.io/script/install-cli.sh -O - | /bin/bash
```

Uninstall

```bash
wget -q https://kcl-lang.io/script/uninstall-cli.sh -O - | /bin/bash
```

#### Windows

Install or upgrade the latest windows KCL to $Env:SystemDrive\kclvm\bin and add this directory to User PATH environment variable.
Expand All @@ -50,6 +62,12 @@ Install or upgrade the latest windows KCL to $Env:SystemDrive\kclvm\bin and add
powershell -Command "iwr -useb https://kcl-lang.io/script/install-cli.ps1 | iex"
```

Uninstall

```shell
powershell -Command "iwr -useb https://kcl-lang.io/script/uninstall-cli.ps1 | iex"
```

### Homebrew (MacOS)

- Install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ $env:PATH += ";{install-location};"
curl -fsSL https://kcl-lang.io/script/install-cli.sh | /bin/bash
```

卸载

```bash
curl -fsSL https://kcl-lang.io/script/uninstall-cli.sh | /bin/bash
```

#### Linux

将 KCL linux 最新版本安装到 /usr/local/bin
Expand All @@ -42,12 +48,24 @@ curl -fsSL https://kcl-lang.io/script/install-cli.sh | /bin/bash
wget -q https://kcl-lang.io/script/install-cli.sh -O - | /bin/bash
```

卸载

```bash
wget -q https://kcl-lang.io/script/uninstall-cli.sh -O - | /bin/bash
```

#### Windows

将 KCL windows 最新版本安装到 $Env:SystemDrive\kclvm\bin,并将该目录添加到用户 PATH 环境变量中。

```bash
powershell -Command "iwr -useb https://kcl-lang.io/script/install-cli.ps1 | iex"
wget -q https://kcl-lang.io/script/uninstall-cli.sh -O - | /bin/bash
```

卸载

```shell
powershell -Command "iwr -useb https://kcl-lang.io/script/uninstall-cli.ps1 | iex"
```

#### Homebrew (MacOS)
Expand Down
45 changes: 45 additions & 0 deletions static/script/uninstall-cli.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# ------------------------------------------------------------
# Uninstallation script for KCL Binary
# ------------------------------------------------------------
param (
[string]$KCLRoot = "$Env:SystemDrive\kclvm"
)
Write-Output "Starting KCL uninstallation..."
$ErrorActionPreference = 'stop'

# Constants
$KCLCliFileName = "kcl.exe"
$KCLCliFileBinPath = "${KCLRoot}\bin"
$KCLCliFilePath = "${KCLCliFileBinPath}\${KCLCliFileName}"

# Remove KCL binary files
if (Test-Path $KCLCliFileBinPath) {
Write-Output "Removing KCL files from $KCLCliFileBinPath"
Remove-Item -Recurse -Force $KCLCliFileBinPath
} else {
Write-Output "KCL binary files not found. Skipping..."
}

# Remove KCL Root if it's empty
if (Test-Path $KCLRoot) {
if (!(Get-ChildItem -Path $KCLRoot -Recurse)) {
Write-Output "Removing empty KCL Root directory: $KCLRoot"
Remove-Item -Force $KCLRoot
} else {
Write-Output "KCL Root directory is not empty, skipping removal: $KCLRoot"
}
}

# Remove KCLRoot from User Path environment variable
Write-Output "Removing $KCLRoot from User Path Environment variable..."
$UserPathEnvironmentVar = Environment::GetEnvironmentVariable("PATH", "User")
if ($UserPathEnvironmentVar -like "*$KCLRoot*") {
$NewUserPath = ($UserPathEnvironmentVar -split ';' | Where-Object { $_ -ne $KCLRoot -and $_ -ne $KCLCliFileBinPath }) -join ';'
Environment::SetEnvironmentVariable("PATH", $NewUserPath, "User")
Write-Output "KCL directory removed from User Path."
} else {
Write-Output "KCL directory not found in User Path. Skipping..."
}

Write-Output "KCL has been uninstalled successfully."
Write-Output "Please restart your system or log off and on for the changes to take effect."