# Uninstalling

> **Warning:** This product is in Beta stage and we may release breaking changes. The documentation here matches the release version listed in the table of contents.

The SonarQube CLI has no single uninstall command. The SonarQube CLI installs itself in a few well-defined locations, and removing it is a matter of deleting them in order.

## Step 1: Clear saved tokens from the keychain

Revoke and remove saved tokens cleanly while the CLI binary and its state are still in place:

```bash
sonar auth purge
```

If you've already removed the CLI or `state.json` and need to clean up tokens afterwards, open your OS keychain manually and remove every entry whose service name is `sonarqube-cli`.

## Step 2: Remove the binary and PATH entry

{% tabs %}
{% tab title="MACOS, LINUX" %}

```bash
rm -rf ~/.local/share/sonarqube-cli
```

Then edit your shell profile (`~/.bashrc`, `~/.zshrc`, `~/.bash_profile`, or `~/.profile`) and remove this line:

```bash
export PATH="$HOME/.local/share/sonarqube-cli/bin:$PATH"
```

Reload your shell (`source ~/.bashrc` or open a new terminal) to drop the `sonar` command from your `PATH`.
{% endtab %}

{% tab title="WINDOWS (POWERSHELL)" %}
Delete the install directory:

```powershell
Remove-Item -Recurse -Force "$env:LOCALAPPDATA\sonarqube-cli"
```

Then remove the install path from your user `PATH`:

1. Open **System Properties** > **Environment Variables**.
2. Edit the user-level `Path` variable.
3. Remove the entry pointing to `…\sonarqube-cli\bin`.
4. Sign out and back in (or open a new PowerShell session) for the change to take effect.
   {% endtab %}
   {% endtabs %}

## Step 3: Remove CLI state and auxiliary binaries

```bash
rm -rf ~/.sonar/sonarqube-cli
```

This wipes:

* `state.json` (your active connection, telemetry preferences, integration registry)
* Auxiliary scanner binaries
* CLI logs
* Globally-installed Git hooks (from `sonar integrate git --global`)

## Step 4: Remove agent integrations

If you ran `sonar integrate claude` or `sonar integrate copilot`:

* **Global installs:** delete the SonarQube hook files inside `~/.claude/` or `~/.copilot/`, and remove the SonarQube MCP server entry from your Claude or Copilot configuration.
* **Project installs:** delete the SonarQube-related files inside your repo's `.claude/` or Copilot configuration directory.

If you ran `sonar integrate git`:

* **Per-repo (plain Git hooks):** delete `.git/hooks/pre-commit` and `.git/hooks/pre-push` if they were installed by the CLI.
* **Per-repo (Husky or pre-commit framework):** remove the SonarQube entry from your Husky scripts or `.pre-commit-config.yaml`.
* **Globally:** `git config --global --unset core.hooksPath` and delete `~/.sonar/sonarqube-cli/hooks/` (handled by Step 2 if you removed `~/.sonar/sonarqube-cli`).

## Step 5: Verify the removal

```bash
which sonar          # should return nothing
ls ~/.sonar          # should not contain sonarqube-cli
```

## Related pages <a href="#related-pages" id="related-pages"></a>

* [State and storage](/sonarqube-cli/administration/state-and-storage.md)
* [Updating the CLI](/sonarqube-cli/administration/self-update.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sonarsource.com/sonarqube-cli/administration/uninstall.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
