# Uninstall & Clean Reinstall

Removing Swarmfile from a machine is straightforward, with one important distinction: **repairing** an install and **removing** one are different operations, and repair is almost always what you want.

If the app is misbehaving (a broken mount, a missing CLI tool, a half-applied update), use **Diagnostics → Reinstall…** or, from the command line, `sudo swarmfile-doctor --repair` instead (on Windows, from an administrator prompt; add `--yes` to skip its confirmation prompt). A repair reinstalls the full package and **keeps** your cache, queued uploads, config, and sign-in; removing the app and its data does not.

A repair stops the engine briefly while the installer runs (on Windows the drive is detached cleanly first) and it reconnects when the install finishes; queued work is unaffected.

Everything below is for a deliberate removal - decommissioning a laptop, handing it to someone else, or a truly clean slate.

## Before you remove anything

Three things live only on this machine and are lost when you delete its data:

1. **Queued uploads.** Saves that haven't reached the hub yet live in the local database. Check `swarmfile status` (the `pending uploads` / `commits pending` counters) and `swarmfile uploads --wait`; wait for zero, or accept losing those changes.
2. **Stuck saves.** `swarmfile sync stuck` lists saves the hub keeps refusing. Export or resolve them before wiping the cache - they will not come back.
3. **Reservations and locks.** `swarmfile offline return` releases any Pack & Go reservations this machine holds; checkout locks you took expire on their own lease, but releasing them now is neighborly. If this machine runs a **seed node**, disable seed mode first (`swarmfile seed disable`) so the org's discovery list doesn't keep advertising it.

Anything staged in a changelist that has been **parked** is kept on the hub and can be resumed from another machine; unsent changelist work is local and goes with the cache.

One more piece of wiring is separate from the app install: if this machine used a repository as a [git-LFS](https://swarmfile.com/docs/guides/git-lfs) server, run `swarmfile-lfs uninstall` to remove the custom-transfer adapter from your git configuration. Uninstalling the app does not do that for you.

## Windows

1. **Quit the Desktop App** from the tray (including any "quit engine" option so the mount dismounts). The uninstaller stops the engine and tray itself (with a force-kill backstop), but quitting first avoids holding the mount open. If uploads are still in flight, Swarmfile drains them before stopping; after about 30 seconds it asks whether to abandon the remaining saves or keep waiting.
2. **Uninstall from Settings → Apps → Swarmfile → Uninstall.** For scripted removal, find the product code and call `msiexec`:
   ```powershell
   $key = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
                        'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall' |
     Where-Object { $_.GetValue('DisplayName') -match 'Swarmfile' } | Select-Object -First 1
   msiexec /x $key.PSChildName /qn /norestart
   ```
   If the install came from the bundled `Setup.exe`, its uninstaller lives in `ProgramData\Package Cache`; Settings → Apps invokes it with `/uninstall` for you.
3. The uninstaller removes the program files (`C:\Program Files\Swarmfile`), the `PATH` entry, the `swarmfile://` protocol registration, the inbound UDP firewall rules, the Explorer overlay handlers, the Start Menu shortcut, the per-machine `Run` entries, and the **Swarmfile Updater** scheduled task. WinFsp, the VC++ Redistributable, and WebView2 are chain prerequisites and deliberately stay installed.
4. **Per-user data is deliberately left behind** (uninstalling for one user shouldn't wipe another's cache):
   ```powershell
   Remove-Item -Recurse -Force "$env:LOCALAPPDATA\swarmfile"
   ```
   This removes the cache, queued uploads, config, and sign-in for that user only. One leftover is harmless: `HKCU\Software\Swarmfile\MountPoint` (the remembered drive letter), which the MSI doesn't own.

To reinstall, run the bundled `Setup.exe` again - or a **repair** if you only wanted the app fixed. If you downloaded a fresh `Setup.exe`, expect the SmartScreen prompt again; [Getting Started](https://swarmfile.com/docs/guides/getting-started#windows-the-smartscreen-prompt) walks through it.

## macOS

The `.pkg` install is machine-wide: the app in `/Applications`, LaunchAgents in `/Library/LaunchAgents`, and CLI symlinks in `/usr/local/bin`. Removing it takes a few commands; run the `launchctl` lines as the logged-in user and the `rm` lines with `sudo`.

1. Quit the Desktop App, then stop its background services:
   ```bash
   launchctl bootout gui/$UID/dev.swarmfile.tray 2>/dev/null
   launchctl bootout gui/$UID/dev.swarmfile.engine 2>/dev/null
   ```
2. Remove the app, the agents, the CLI links, and the bundled FUSE-T pieces:
   ```bash
   sudo rm -rf /Applications/Swarmfile.app
   sudo rm -f /Library/LaunchAgents/dev.swarmfile.engine.plist \
              /Library/LaunchAgents/dev.swarmfile.tray.plist
   sudo rm -f /usr/local/bin/swarmfile /usr/local/bin/swarmfile-*
   sudo rm -f /usr/local/lib/libfuse3.4.dylib /usr/local/lib/libfuse3.dylib \
              /usr/local/lib/libfuse-t-1.2.7.dylib /usr/local/lib/libfuse-t.dylib
   sudo rm -rf "/Library/Application Support/fuse-t"
   sudo pkgutil --forget dev.swarmfile
   ```
3. Remove the per-user data (cache, queue, config):
   ```bash
   rm -rf ~/Library/Caches/swarmfile ~/.cache/swarmfile ~/.config/swarmfile
   ```
   The engine's cache and config are the `~/.cache/swarmfile` / `~/.config/swarmfile` pair; `~/Library/Caches/swarmfile` covers `.dmg` and other install layouts. Repeat per user profile.
4. Remove the engine's macOS Keychain items - the sign-in token and this device's end-to-end key live there, not in the files above. Each item's service is `com.swarmfile.engine`; open **Keychain Access**, search for that string, and delete every match (or `security delete-generic-password -s com.swarmfile.engine`, repeated for each item). Do this per user profile too; the login keychain is per user.

If Finder or an app still shows the drive, it is a stale mount from a killed helper: log out and back in, or reboot, before wiping. To fix an install you intend to keep, use **Diagnostics → Reinstall…** or `sudo swarmfile-doctor --repair` instead. On a Mac where the app was copied from the `.dmg`, `--repair` refuses (that copy is owned by your user, not root); install the `.pkg` from [Downloads](https://swarmfile.com/downloads) instead.

## Linux

1. **Quit the Desktop App and the engine for each logged-in user first** - the package's pre-remove script disables the systemd units but does not stop services already running in your session, so a removed engine can keep serving its mount until you log out or kill it.
2. **Remove the package:**
   ```bash
   sudo apt remove swarmfile      # remove the app and units
   sudo apt purge swarmfile       # also remove the packaged /etc/swarmfile
   ```
   Removal disables the per-user `swarmfile-engine` and `swarmfile-tray` systemd units; nothing else (firewall, mounts) is touched. If a mount is still present after removal, unmount it (`fusermount -u <mount point>`) or log out.
3. **Remove the per-user data** for each user who signed in:
   ```bash
   rm -rf ~/.cache/swarmfile ~/.config/swarmfile
   ```
   That covers the cache, queue, and config. If you ran a seed or a headless engine with its own `SWARMFILE_CACHE_DIR`, remove that directory too.
4. **Remove the keyring entries.** Where a desktop keyring is available (GNOME Keyring or KWallet), the sign-in token and this device's end-to-end key live there under the service name `com.swarmfile.engine` - delete those items in **Passwords and Keys** (Seahorse) or KWallet. On a headless/seed machine with no keyring, the engine falls back to a file in the cache directory, which step 3 already removed.

## What lives where

| Platform | Application | Per-user data (cache, queue, config, sign-in) |
|---|---|---|
| Windows | `C:\Program Files\Swarmfile` | `%LOCALAPPDATA%\swarmfile` (DPAPI secret store included) |
| macOS | `/Applications/Swarmfile.app`, `/Library/LaunchAgents`, `/usr/local/bin`, `/usr/local/lib/libfuse*`, `/Library/Application Support/fuse-t` | `~/.cache/swarmfile` (cache, queue, logs) + `~/.config/swarmfile` (config) + Keychain items (service `com.swarmfile.engine`) |
| Linux | package files, per-user systemd units | `~/.cache/swarmfile` + `~/.config/swarmfile`; `/etc/swarmfile` (purge only); keyring items (service `com.swarmfile.engine`) where a secret service runs |

The cache directory is also where **log files** live, so if you're removing the machine as part of a support case, copy that directory aside first.

## Clean reinstall

To start completely fresh on the same machine:

1. Follow the uninstall steps above, including deleting the per-user data.
2. Install the current package from [swarmfile.com/downloads](https://swarmfile.com/downloads) - or, on macOS, make sure it's the **`.pkg`**: the `.dmg` doesn't set up the engine service or the CLI on `PATH`.
3. Sign in again and re-open the repository. The mount comes back where the Drive Letter / mount-point settings say; nothing on the hub is affected by the reinstall.

## Where to go next

- [Release Channels & Updates](https://swarmfile.com/docs/reference/release-channels-and-updates) - how updates work and what a repair does.
- [Supported Platforms & System Requirements](https://swarmfile.com/docs/reference/platforms-and-system-requirements) - installer names and per-platform layout.
- [Deploying to Your Team](https://swarmfile.com/docs/admin/deploying-to-your-team) - removing or re-provisioning machines at fleet scale.
