> For the complete documentation index, see [llms.txt](https://docs.sonarsource.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sonarsource.com/sonarqube-cli/administration/uninstall.md).

# Uninstalling

To clear credentials, binaries, integrations, and cached CLI files in one step, run [Reset the CLI](/sonarqube-cli/administration/system-reset.md) first. That command does not remove the `sonar` binary from your `PATH`. Use the steps below for a full uninstall.

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

While the CLI binary is still available, log out of the saved connection:

```bash
sonar auth logout
```

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`, `sonar integrate copilot`, `sonar integrate codex`, or `sonar integrate cursor`:

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

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>

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
