> ## Documentation Index
> Fetch the complete documentation index at: https://docs.boat.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Install Wine

> Install Wine and the Windows runtimes in a sandbox with one script.

Run this script one time inside the sandbox. It takes about 5 minutes.

## Run the script

1. Save the script below as `install-wine.sh` on your computer.

2. Send it to the sandbox in one of these ways:

   | Surface | How |
   | - | - |
   | CLI | `boat ssh bx_f7k2q9hd 'bash -s' < install-wine.sh` |
   | API | Pass the script as the `command` of [`POST /sandboxes/{sandboxId}/commands`](/api/reference/agent/execute-sandbox-command), with `detached: true`. |
   | SDK | Pass the script to the `command` call, with `detached: true`. |

3. For the API and the SDK, poll the command status until the command finishes.

<Warning>
  Without `detached`, the command stops after its 30-second default timeout. Wine is then only half installed.
</Warning>

```bash install-wine.sh theme={null}
set -e
sudo dpkg --add-architecture i386
sudo mkdir -pm755 /etc/apt/keyrings
sudo wget -qO /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
sudo wget -qNP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/noble/winehq-noble.sources
printf 'Package: libgd3\nPin: release o=Ubuntu\nPin-Priority: 1001\n' | sudo tee /etc/apt/preferences.d/wine-libgd3
sudo apt-get update -qq
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --allow-downgrades --no-install-recommends \
  winehq-staging mesa-vulkan-drivers mesa-vulkan-drivers:i386 cabextract p7zip-full
sudo wget -qO /usr/local/bin/winetricks https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
sudo chmod +x /usr/local/bin/winetricks
export DISPLAY=:0
WINEDLLOVERRIDES="mscoree,mshtml=" wineboot -i
winetricks -q corefonts vcrun2022 dxvk d3dcompiler_47
wine --version
```

## What each part does

| Part | Why it is there |
| - | - |
| **WineHQ staging** | Ubuntu's own Wine is version 9. Steam, Paint.NET 5.2 and Direct3D games need Wine 11 or newer. |
| **The `libgd3` pin** | The sandbox has a PHP repository. Its `libgd3` exists only for 64-bit. 32-bit Wine needs the same version for both. The pin selects Ubuntu's version. As a side effect, PHP's `gd` extension is removed. |
| **`mesa-vulkan-drivers`** | A sandbox has no GPU. This software Vulkan driver lets DXVK run Direct3D 8 to 11 on the CPU. |
| **`WINEDLLOVERRIDES="mscoree,mshtml="`** | A new Wine set-up opens a "Wine Mono Installer" window and waits for a click. This setting skips that window. Apps that need .NET get Microsoft's runtime from winetricks instead. |
| **winetricks** | Installs Microsoft's free redistributables: core fonts, the Visual C++ 2015 to 2022 runtime, DXVK and the Direct3D shader compiler. |

## Next step

[Run an app](/windows-apps/run-apps).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.