# Installation

> Install the Aphrody runtime with the install script, npm, or a release archive.

## Overview

The Aphrody runtime ships as a single executable, `bun`. Inside an Aphrody installation, the distribution installs and updates it. Elsewhere, install it with the install script, npm, or a release archive from [GitHub releases](https://github.com/aphrody-labs/bun/releases).

<Tip>After installation, verify with `bun --version` and `bun --revision`.</Tip>

## Installation

<Tabs>
  <Tab title="Linux & macOS">

    <CodeGroup>
      ```bash curl icon="globe"
      curl -fsSL https://bun.aphrody.com/install.sh | bash
      ```

    </CodeGroup>
    <Note>
      **Linux users:** You need the `unzip` package to install Bun (`sudo apt install unzip`). The script picks the musl archive on Alpine and other musl systems.
    </Note>
    <Note>
      **macOS users:** The latest release has no macOS binary. Install `aphrody-v1.4.3-aphrody.2`, the last release with macOS builds (`bash -s aphrody-v1.4.3-aphrody.2`), or [build from source](https://bun.aphrody.com/docs/project/contributing).
    </Note>

  </Tab>

  <Tab title="Windows">
    <CodeGroup>
      ```powershell PowerShell icon="terminal"
      powershell -c "irm https://bun.aphrody.com/install.ps1|iex"
      ```

    </CodeGroup>
    <Warning>
      Bun requires Windows 10 version 1809 or later.
    </Warning>

  </Tab>

  <Tab title="npm">
    <CodeGroup>

    ```bash npm icon="npm"
    npm install -g @aphrody/bun-runtime
    ```

    </CodeGroup>

    `@aphrody/bun-runtime` installs the binary for the current platform through optional dependencies. It is published after the GitHub release, so its version can lag behind.

  </Tab>
</Tabs>

The scripts are [`scripts/aphrody/install.sh`](https://github.com/aphrody-labs/bun/blob/main/scripts/aphrody/install.sh) and [`install.ps1`](https://github.com/aphrody-labs/bun/blob/main/scripts/aphrody/install.ps1). They download the release archive for the current platform, check it against the release's `SHA256SUMS.txt`, and install `bun` and `bunx` into `$BUN_INSTALL/bin` (default `~/.bun/bin`). Set `GITHUB_TOKEN` to authenticate the release lookup.

To check that Bun was installed successfully, open a new terminal window and run:

```bash terminal icon="terminal"
bun --version
# Output: 1.4.3-aphrody.4

# See the release and the commit of aphrody-labs/bun that you're using
bun --revision
# Output: 1.4.3-aphrody.4+86ad19e8c
```

`bun --version` prints the component version. `Bun.version` and `process.versions.bun` keep the upstream Bun base version (`1.4.3`).

<Warning>
  If you've installed Bun but are seeing a `command not found` error, you may have to manually add the installation
  directory (`~/.bun/bin`) to your `PATH`.
</Warning>

<Accordion title="Add Bun to your PATH">
  <Tabs>
    <Tab title="macOS & Linux">
      <Steps>
        <Step title="Determine which shell you're using">
        ```bash terminal icon="terminal"
        echo $SHELL
        # /bin/zsh  or /bin/bash or /bin/fish
        ```
        </Step>
        <Step title="Open your shell configuration file">
          - For bash: `~/.bashrc`
          - For zsh: `~/.zshrc`
          - For fish: `~/.config/fish/config.fish`
        </Step>

        <Step title="Add the Bun directory to PATH">
          Add these lines to your configuration file:
          ```bash terminal icon="terminal"
          export BUN_INSTALL="$HOME/.bun"
          export PATH="$BUN_INSTALL/bin:$PATH"
          ```
        </Step>

        <Step title="Reload your shell configuration">
          ```bash terminal icon="terminal"
          source ~/.bashrc  # or ~/.zshrc
          ```
        </Step>
      </Steps>
    </Tab>
    <Tab title="Windows">
      <Steps>
        <Step title="Determine if the bun binary is properly installed">
        ```bash terminal icon="terminal"
        & "$env:USERPROFILE\.bun\bin\bun" --version
        ```

        If the command runs successfully but `bun --version` is not recognized, bun is not in your system's PATH. To fix this, open a PowerShell terminal and run the following command:

        ```bash terminal icon="terminal"
        [System.Environment]::SetEnvironmentVariable(
          "Path",
          [System.Environment]::GetEnvironmentVariable("Path", "User") + ";$env:USERPROFILE\.bun\bin",
          [System.EnvironmentVariableTarget]::User
        )
        ```

        </Step>
        <Step title="Restart your terminal">
           Restart your terminal and test with `bun --version`.

          ```bash terminal icon="terminal"
          bun --version
          ```
        </Step>
      </Steps>
    </Tab>

  </Tabs>
</Accordion>

---

## Upgrading

Once installed, the binary can upgrade itself to the latest `aphrody-v*` release:

```bash terminal icon="terminal"
bun upgrade
```

---

## Installing Older Versions

Pass an upstream base version (the newest `aphrody.<n>` release of that base) or an exact release tag to the install script.

<Tabs>
  <Tab title="Linux & macOS">
    ```bash terminal icon="terminal"
    curl -fsSL https://bun.aphrody.com/install.sh | bash -s 1.4.3
    curl -fsSL https://bun.aphrody.com/install.sh | bash -s aphrody-v1.4.3-aphrody.2
    ```

  </Tab>
  <Tab title="Windows">
    ```powershell PowerShell icon="windows"
    & ([scriptblock]::Create((irm https://bun.aphrody.com/install.ps1))) -Version aphrody-v1.4.3-aphrody.2
    ```

  </Tab>
</Tabs>

---

## Direct Downloads

Release archives are attached to each release on the [releases page](https://github.com/aphrody-labs/bun/releases), with a `SHA256SUMS.txt`. Archive names follow upstream Bun: `bun-<os>-<arch>[-musl].zip`, each containing `bun-<os>-<arch>[-musl]/bun` (`bun.exe` on Windows).

| Archive                  | Platform                 |
| ------------------------ | ------------------------ |
| `bun-linux-x64.zip`      | Linux x64, glibc         |
| `bun-linux-x64-musl.zip` | Linux x64, musl (Alpine) |
| `bun-windows-x64.zip`    | Windows x64              |

The targets of each release are listed in [RELEASES.md](https://github.com/aphrody-labs/bun/blob/main/RELEASES.md). `aphrody-v1.4.3-aphrody.2` also has macOS, Linux ARM64 and Windows ARM64 archives.

<Note>
  A glibc binary needs the glibc version of the system it was built on, or newer. The glibc requirement of each release
  is in its notes. If `bun` fails with `GLIBC_... not found`, use an older release or build from source.
</Note>

---

## CPU Requirements

Bun ships a single x64 binary per platform. It targets the Nehalem microarchitecture (SSE4.2) and selects AVX2/AVX-512
code paths at runtime when the CPU supports them, so there is no separate "baseline" download to choose.

| Platform | Intel Requirement               | AMD Requirement    |
| -------- | ------------------------------- | ------------------ |
| x64      | Nehalem (1st gen Core) or newer | Bulldozer or newer |

<Note>Bun does not support x64 CPUs without the SSE4.2 extension.</Note>

---

## Uninstall

The install scripts only write to `$BUN_INSTALL` (default `~/.bun`). Delete that directory, then remove its `bin` directory from your `PATH` (on Windows, the user `Path`).

```bash macOS & Linux icon="terminal"
rm -rf ~/.bun
```

```powershell Windows icon="windows"
Remove-Item -Recurse -Force "$env:USERPROFILE\.bun"
```

```bash npm icon="npm"
npm uninstall -g @aphrody/bun-runtime
```
