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

# Install a Linux package

> Use provision.installer() to install command-line and desktop apps, and download a script, on Linux.

This file has three `provision.installer()` tests in a Linux sandbox:

* One installs a command-line tool from a `.deb` and runs it.
* One installs a desktop app from a `.deb` and checks that its window opens.
* One downloads a shell script without running it and checks that it exists.

## Watch it run

[https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af5062070c121f49ee8fe5f/replay](https://api-test.testdriver.ai/api/v1/testdriver/testcase/6af5062070c121f49ee8fe5f/replay)

## The test

```javascript title="installer.test.mjs" theme={null}
import { describe, expect, it } from "vitest";
import { TestDriver } from "testdriverai/vitest/hooks";

const isLinux = (process.env.TD_OS || "linux") === "linux";

describe("Provision Installer", () => {
  it.skipIf(!isLinux)(
    "should download and install a .deb package on Linux",
    async (context) => {
      const testdriver = TestDriver(context);
      
      // Install bat (a cat clone with syntax highlighting) using provision.installer
      const filePath = await testdriver.provision.installer({
        url: 'https://github.com/sharkdp/bat/releases/download/v0.24.0/bat_0.24.0_amd64.deb',
      });

      // Verify the file was downloaded
      expect(filePath).toContain('bat');

      // Verify bat was installed by running it
      await testdriver.exec('sh', 'bat --version', 10000);
    },
  );

  it.skipIf(!isLinux)(
    "should install a .deb with missing dependencies and launch its window",
    async (context) => {
      const testdriver = TestDriver(context);

      // Yaak is a Tauri app. Its .deb depends on WebKitGTK and libsoup,
      // which aren't preinstalled, so dpkg alone leaves it unconfigured.
      await testdriver.provision.installer({
        url: 'https://github.com/mountain-loop/yaak/releases/download/v2026.9.0/yaak_2026.9.0_amd64.deb',
        appName: 'Yaak',
      });

      // The package and its dependencies are fully installed
      const status = await testdriver.exec(
        'sh',
        "dpkg-query -W -f='${Status}' yaak",
        10000,
      );
      expect(status).toBe('install ok installed');

      // launch: true (the default) started the app, so its window is on screen
      const result = await testdriver.assert('The Yaak app window is open');
      expect(result).toBeTruthy();
    },
  );

  it.skipIf(!isLinux)(
    "should download a shell script and verify it exists",
    async (context) => {
      const testdriver = TestDriver(context);
      
      // Download a shell script (nvm installer)
      const filePath = await testdriver.provision.installer({
        url: 'https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh',
        launch: false, // Download the script without running it
      });

      // Verify the file was downloaded
      expect(filePath).toContain('install.sh');

      // Verify the file is executable
      const result = await testdriver.exec('sh', `ls -la "${filePath}"`, 10000);
      expect(result).toBeTruthy();
    },
  );
});
```

## How it works

* `provision.installer({ url })` downloads the file, installs it by extension, and returns its path.
* On Linux, a `.deb` is installed with `dpkg`, and missing dependencies are installed with `apt-get`. The step fails if the package still isn't fully installed.
* With `launch: true` (the default), a `.deb` app is started from its `.desktop` entry, then `appName` is focused. That's how the Yaak window opens.
* A `.sh` script is made executable and run.
* `launch: false` makes a `.sh` script executable without running it. It also skips focusing the app when you pass `appName`.
* With `launch: false`, packages such as `.deb` files are still installed.
* `exec('sh', command, timeout)` runs a shell command and returns its output. The test uses it to check that `bat` is installed.
* `it.skipIf(!isLinux)` skips every test when `TD_OS` is set to `windows`.

## Run it

The test is in the [TestDriver SDK repository](https://github.com/testdriverai/testdriverai/tree/main/examples). Clone it, install dependencies, and run the file:

```bash theme={null}
git clone https://github.com/testdriverai/testdriverai
cd testdriverai
npm install
npx vitest run examples/installer.test.mjs
```

The test reads your API key from `TD_API_KEY`. Create a key at [console.testdriver.ai/team/api-keys](https://console.testdriver.ai/team/api-keys). Then set it in your environment or a `.env` file.

## Related

* [Launch apps](https://docs.testdriver.ai/provision.md)
* [exec()](https://docs.testdriver.ai/exec.md)


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