---
title: "更新、回滚和卸载 | Wantastic Docs"
description: "每个操作系统一行命令即可更新或卸载 wantasticd。另外还介绍：自动更新的工作方式、如何关闭、回滚到上一个二进制文件，以及清除所有数据。"
url: "https://wantastic.app/zh/docs/update-and-uninstall"
category: "Install wantasticd"
reading_time: "5 分钟"
---

# 更新、回滚和卸载

每个操作系统一行命令即可更新或卸载 wantasticd。另外还介绍：自动更新的工作方式、如何关闭、回滚到上一个二进制文件，以及清除所有数据。

> **Outcome:** 你可以用一条命令更新或移除 wantasticd，在一分钟内从失败的更新中恢复，并控制自动更新。

## Before you start

- 设备上的 root 或管理员权限。

## 一行命令更新或卸载

选择你的系统。更新会保留认领信息和设置。卸载同样会保留配置，因此以后重新安装时会以同一台设备的身份重新连接。

### Linux / macOS

更新 / 卸载:

```bash
# update
sudo wantasticd update
# uninstall (keeps the config)
curl -fsSL https://get.wantastic.app/install.sh | sudo sh -s -- --uninstall
```

### OpenWrt / Alpine

更新 / 卸载（以 root 身份）:

```sh
# update
wantasticd update
# uninstall (keeps the config)
wget -qO- https://get.wantastic.app/install.sh | sh -s -- --uninstall
```

### BusyBox

在 BusyBox 上手动更新，因为自动更新可能会在那里启动第二个副本。将 <arch> 替换为你的版本。

更新 / 卸载（以 root 身份）:

```sh
# update
cd /tmp && TAG=$(wget -qO- https://get.wantastic.app/latest | cut -d+ -f1) && wget -O w.tgz https://get.wantastic.app/$TAG/wantasticd-linux-<arch>.tar.gz && tar -xzf w.tgz && ./wantasticd version && cp /usr/bin/wantasticd /usr/bin/wantasticd.previous && cp wantasticd /usr/bin/wantasticd.new && mv /usr/bin/wantasticd.new /usr/bin/wantasticd && killall wantasticd
# uninstall (keeps the config)
wget -qO- https://get.wantastic.app/install.sh | sh -s -- --uninstall
```

### Windows

PowerShell（管理员）:

```powershell
# update
wantasticd update
# uninstall (keeps the config)
sc.exe stop wantasticd; sc.exe delete wantasticd; Get-Process wantasticd -ErrorAction SilentlyContinue | Stop-Process -Force; Remove-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Run' -Name 'Wantastic' -ErrorAction SilentlyContinue; Remove-Item -Recurse -Force 'C:\Program Files\Wantastic'
```

> 不要仅为更新而再次运行 install.ps1。它会重新登录，并可能替换掉正常工作的配置。

### Docker

更新 / 卸载:

```bash
# update: rebuild the image, then start the container again
docker build --no-cache -t wantasticd-local --build-arg WANTASTIC_ARCH=amd64 .
docker rm -f wantasticd
# uninstall
docker rm -f wantasticd && docker volume rm wantastic
```

*wantasticd update: 更新在后台运行。服务会以新版本重启。*

```
$ $ sudo wantasticd update
Updating from v1.0.53+9c1e2aa to v1.0.54+377f3c0...
2026/10/29 09:20:11 Running update script for version v1.0.54+377f3c0 (target: /usr/local/bin/wantasticd, log: /tmp/wantasticd-update-3141.log)...
$ $ wantasticd version
wantasticd version v1.0.54+377f3c0
$ $ sudo wantasticd update
No newer release available: current=v1.0.54+377f3c0 offered=v1.0.54+377f3c0
```

> **Tip:** 卸载不会将设备从你的账户中移除。请在控制台 Devices 窗口中删除它（设备行 → Delete）以释放名额。

## 移除所有内容（清除）

--purge 还会删除配置和设备密钥。之后重新安装时需要重新认领。

清除:

```bash
# Linux / macOS
curl -fsSL https://get.wantastic.app/install.sh | sudo sh -s -- --purge
# OpenWrt / Alpine / BusyBox (as root)
wget -qO- https://get.wantastic.app/install.sh | sh -s -- --purge
```

Windows（在卸载命令之后）:

```powershell
Remove-Item -Recurse -Force 'C:\ProgramData\Wantastic'
```

| 平台 | --uninstall 会移除 | --purge 还会移除 |
| --- | --- | --- |
| Linux（systemd） | 单元、二进制文件（以及 .previous/.new）、运行中的进程 | /etc/wantastic、/usrdata/wantastic |
| OpenWrt / OpenRC / SysV | /etc/init.d/wantasticd 及其运行级别链接、二进制文件 | /etc/wantastic |
| BusyBox | init 脚本、inittab 行（然后运行 kill -HUP 1）、二进制文件 | /etc/wantastic |
| macOS | LaunchDaemon 和 LaunchAgent 的 plist 文件、二进制文件 | /Library/Application Support/Wantastic、/Library/Logs/Wantastic |

*卸载: 不使用 --purge 时配置会保留，因此以后重新安装时会以同一台设备的身份重新连接。*

```
$ $ curl -fsSL https://get.wantastic.app/install.sh | sudo sh -s -- --uninstall
=== Uninstalling wantasticd ===
Removed "/etc/systemd/system/multi-user.target.wants/wantasticd.service".
Configuration kept (use --purge to remove it).
wantasticd uninstalled.
```

## 自动更新的工作方式

- 自动更新默认开启。守护进程在启动 1 分钟后检查新版本，之后每小时检查一次。
- 它只安装更新的版本，绝不降级。
- 它会将旧的二进制文件保留为 .previous，重启服务并检查其是否正常。如果不正常，则恢复旧的二进制文件。
- 失败会被记录，并在下一次每小时检查时重试。

## 关闭自动更新

在服务运行的命令中添加 --no-auto-update。

### systemd

覆盖 ExecStart:

```bash
sudo systemctl edit wantasticd
# [Service]
# ExecStart=
# ExecStart=/usr/local/bin/wantasticd connect --config "/etc/wantastic/config.conf" --no-auto-update
sudo systemctl restart wantasticd
wantasticd status | grep 'Auto update'
```

### OpenWrt（procd）

编辑命令行:

```sh
sed -i "s|connect --config '/etc/wantastic/config.conf'|connect --config '/etc/wantastic/config.conf' --no-auto-update|" /etc/init.d/wantasticd
/etc/init.d/wantasticd restart
```

### OpenRC

编辑 command_args:

```sh
# /etc/init.d/wantasticd
command_args="connect --config '/etc/wantastic/config.conf' --no-auto-update"
rc-service wantasticd restart
```

### BusyBox

编辑 exec 行:

```sh
sed -i 's| connect --config \(.*\)$| connect --config \1 --no-auto-update|' /etc/init.d/wantasticd
killall wantasticd
```

### macOS

在 plist 中的 <string>--tray=false</string> 之后添加 <string>--no-auto-update</string>，然后重新加载。

重新加载 LaunchDaemon:

```bash
sudo nano /Library/LaunchDaemons/com.wantastic.wantasticd.plist
sudo launchctl bootout system/com.wantastic.wantasticd
sudo launchctl bootstrap system /Library/LaunchDaemons/com.wantastic.wantasticd.plist
```

### Windows

PowerShell（管理员）:

```powershell
sc.exe config wantasticd binPath= '"C:\Program Files\Wantastic\wantasticd.exe" connect --config "C:\ProgramData\Wantastic\config.conf" --tray=false --no-auto-update'
Restart-Service wantasticd
```

> **Operational note:** 重新运行安装程序会重写服务，且不带 --no-auto-update。之后请重新应用你的修改。

## 回滚到上一个二进制文件

每次安装和更新都会将旧的二进制文件以 .previous 的形式保留在当前文件旁边。

### Linux（systemd）

回滚:

```bash
sudo systemctl stop wantasticd
sudo mv /usr/local/bin/wantasticd.previous /usr/local/bin/wantasticd
sudo systemctl start wantasticd
```

### OpenWrt

回滚:

```sh
/etc/init.d/wantasticd stop
mv /usr/bin/wantasticd.previous /usr/bin/wantasticd
/etc/init.d/wantasticd start
```

### macOS

回滚:

```bash
sudo launchctl bootout system/com.wantastic.wantasticd
sudo mv /usr/local/bin/wantasticd.previous /usr/local/bin/wantasticd
sudo launchctl bootstrap system /Library/LaunchDaemons/com.wantastic.wantasticd.plist
```

### Windows

PowerShell（管理员）:

```powershell
Stop-Service wantasticd
Get-Process wantasticd -ErrorAction SilentlyContinue | Stop-Process -Force
Rename-Item "C:\Program Files\Wantastic\wantasticd.exe" wantasticd.exe.bad
Rename-Item "C:\Program Files\Wantastic\wantasticd.exe.previous" wantasticd.exe
Start-Service wantasticd
```

> **Warning:** 自动更新会在一小时内再次将你升级到新版本。如需停留在旧版本，请关闭自动更新（见上文），并告知支持团队哪个版本出现了问题。

## Verify the result

- 更新后：wantasticd version 显示新版本，status 显示 Connected。
- 关闭更新后：wantasticd status 显示 Auto update: false。
- 卸载后：which wantasticd 没有任何输出，服务也已不存在。

## Common issues

### 更新失败，旧版本继续运行。

```
Self-update failed; agent remains active and will retry on the next scheduled check: …
```

- **Where:** 服务日志
- **Likely cause:** 下载、校验或重启失败。代理继续以当前版本运行。
- **Fix:** 查看更新日志，解决问题原因（网络、磁盘空间），然后再次更新。

查看日志，然后重试:

```bash
ls -t /tmp/wantasticd-update-*.log | head -n 1 | xargs tail -n 50
sudo wantasticd update
```

### 更新自动回滚了。

```
Error: updated service failed health verification; restoring previous binary
```

- **Where:** 更新日志
- **Likely cause:** 新版本未能正常启动，已恢复为上一个版本。
- **Fix:** 设备上无需修复。请将版本号告知支持团队，并在修复版本发布前关闭自动更新。

### 在容器或自定义服务中，更新拒绝运行。

```
Error: no supported service manager found; refusing an unverifiable update
```

- **Where:** 更新日志
- **Likely cause:** 没有可重启的 launchd、systemd、procd、OpenRC 或 init.d 服务。
- **Fix:** 使用 --no-auto-update，并通过替换二进制文件（或重新构建镜像）来更新。

### 文件系统已满或为只读时，更新失败。

```
Error: cannot write to /usr/bin (check permissions)
```

- **Where:** 更新日志
- **Likely cause:** 二进制文件所在目录为只读或已满（"Error: cannot back up <bin>" 也是同一问题）。
- **Fix:** 释放一些空间，然后再次更新。

检查空间，然后重试:

```bash
df -h
sudo wantasticd update
```

### 更新超时。

```
update attempt timed out after 7m0s (log kept at /tmp/wantasticd-update-XXXX.log)
```

- **Where:** 服务日志
- **Likely cause:** 链路非常慢，或服务重启卡住了。
- **Fix:** 在链路状况较好时手动运行更新。对于慢速链路，请调高 WANTASTIC_UPDATE_DOWNLOAD_TIMEOUT。

重试:

```bash
sudo wantasticd update
```

### 自行构建的二进制文件拒绝更新。

```
Invalid update version: parse current version: version "dev" is not major.minor.patch
```

- **Where:** wantasticd update
- **Likely cause:** 本地构建的版本显示为 dev。
- **Fix:** 使用安装程序安装官方发布版本。

安装官方发布版本:

```bash
curl -fsSL https://get.wantastic.app/install.sh | sudo sh
```

### Windows 更新已回滚。

```
update-finish: wantasticd unhealthy after update to <v>: …; restoring previous binary
```

- **Where:** Windows 更新助手
- **Likely cause:** 新服务未能正常启动。有问题的版本被保留为 wantasticd.exe.failed。
- **Fix:** 不紧急，上一个版本仍在运行。如果你还看到 "update-finish: previous binary did not start either"，请使用 install.ps1 -Token 重新安装。

### 在 Windows 上无法删除服务。

```
[SC] DeleteService FAILED 1072: The specified service has been marked for deletion.
```

- **Where:** sc.exe
- **Likely cause:** services.msc 或其他工具仍打开着该服务。
- **Fix:** 关闭 services.msc 和事件查看器，或重启电脑。然后再次运行卸载命令。

## Continue with

- [wantasticd CLI reference and operations](https://wantastic.app/zh/docs/wantasticd): The most used wantasticd commands first, then every command and flag, environment variables, config and state paths per OS, log lines, local access, exit node, and the claim flow (genkey / --wait-claim).
- [Choose your install method](https://wantastic.app/zh/docs/install-overview): Find your device in one table and copy one command. Most devices install in 2 minutes: install, scan a QR code, click Claim Device.
- [Update and rollback errors](https://wantastic.app/zh/docs/errors-update): Fix self-update failures, read the update log and roll back to the previous binary.
- [Install on Windows](https://wantastic.app/zh/docs/install-windows): Install wantasticd on Windows 10/11 and Windows Server: open PowerShell as Administrator, paste one line, approve the device in your browser.
- [Install on macOS](https://wantastic.app/zh/docs/install-macos): Install wantasticd on a Mac (Apple silicon or Intel) in 2 minutes: one Terminal command, scan a QR code, click Claim Device.
- [Install on Debian and Ubuntu](https://wantastic.app/zh/docs/install-debian-ubuntu): Install wantasticd on Debian, Ubuntu, Mint and Proxmox in 2 minutes: one command, scan a QR code, click Claim Device.
