import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

:::tip
The `dagger` CLI is available for installation on macOS, Linux, and Windows to run locally or in a CI environment.
:::

Install the `dagger` CLI following the steps below.

<Tabs>
<TabItem value="macos">

We assume that you have [Homebrew](https://brew.sh/) installed. If you do, you can install `dagger` with a single command:

```shell
brew install dagger/tap/dagger
```

This installs `dagger` in:

```shell
type dagger
# macOS ARM:
dagger is /opt/homebrew/bin/dagger
# macOS Intel:
dagger is /usr/local/bin/dagger
```

If you do not have Homebrew installed, or you want to install a specific version of `dagger`, you can run:

```shell
cd /usr/local
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.9.7 sh

./bin/dagger version
dagger 0.9.7 (GIT_SHA) darwin/arm64
```

If your user account doesn't have sufficient privileges to install in `/usr/local` and `sudo` is available, use the following command instead:

```shell
cd /usr/local
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.9.7 sudo sh
```

</TabItem>

<TabItem value="linux">

The quickest way of installing `dagger` on Linux is to run the following command:

```shell
cd /usr/local
curl -L https://dl.dagger.io/dagger/install.sh | sh
```

This installs `dagger` in `/usr/local/bin`:

```shell
type dagger
dagger is /usr/local/bin/dagger
```

If your user account doesn't have sufficient privileges to install in `/usr/local` and `sudo` is available, use the following command instead:

```shell
cd /usr/local
curl -L https://dl.dagger.io/dagger/install.sh | sudo sh
```

Alternatively, install the Dagger Engine to a different location, such as your home directory:

```shell
cd ~
curl -L https://dl.dagger.io/dagger/install.sh | sh
```

If you want to install a specific version of `dagger`, you can run:

```shell
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.9.7 sh

./bin/dagger version
dagger 0.9.7 (GIT_SHA) linux/amd64
```

</TabItem>

<TabItem value="windows">

`dagger` can be installed in Windows via an installation PowerShell script.

If you want to use the installation script, PowerShell 7.0 or newer is required. From PowerShell, run:

```Powershell
Invoke-WebRequest -UseBasicParsing -Uri https://dl.dagger.io/dagger/install.ps1 | Invoke-Expression
```

If you want to install Dagger to a different location, pass in a location to the script with the `-InstallPath` parameter.

```Powershell
$script = Invoke-WebRequest -UseBasicParsing -Uri https://dl.dagger.io/dagger/install.ps1
$params = "-InstallPath C:\temp"
"$script $params" | Invoke-Expression
```

If you want to install a specific version of `dagger`, pass in a version number with the `-DaggerVersion` parameter.

```Powershell
$script = Invoke-WebRequest -UseBasicParsing -Uri https://dl.dagger.io/dagger/install.ps1
$params = "-DaggerVersion 0.9.7"
"$script $params" | Invoke-Expression
```

Without passing in the `-InstallPath`, We'll save everything under `<your home folder>\dagger`

Check that `dagger` is installed correctly by opening a `Command Prompt` terminal and run:

```shell
where dagger
C:\<your home folder>\dagger\dagger.exe
```

</TabItem>

</Tabs>
