dagger/dagger · critical · AggregateError

${downloadError.message}\nfailed to use CLI from PATH "${thi

Error message

${downloadError.message}\nfailed to use CLI from PATH "${this.binPath}": ${sessionError.message}

What it means

The SDK first tried to download the pinned CLI, which failed (downloadError), then fell back to running a CLI already on PATH, which also failed. Both errors are combined into an AggregateError reporting the original download failure plus the reason the PATH binary could not run a session.

Source

Thrown at sdk/typescript/src/provisioning/bin.ts:84

  async Connect(opts: ConnectOpts): Promise<GraphQLClient> {
    let downloadError: Error | undefined

    if (!this.binPath) {
      try {
        this.binPath = await this.downloadCLI(opts.LogOutput)
      } catch (e) {
        downloadError = e instanceof Error ? e : new Error(String(e))
        this.binPath = this.fallbackToLocalCLI(downloadError, opts.LogOutput)
      }
    }

    try {
      return await this.runEngineSession(this.binPath, opts)
    } catch (e) {
      if (downloadError) {
        const sessionError = e instanceof Error ? e : new Error(String(e))
        throw new AggregateError(
          [downloadError, sessionError],
          `${downloadError.message}\nfailed to use CLI from PATH "${this.binPath}": ${sessionError.message}`,
          { cause: e },
        )
      }
      throw e
    }
  }

  private async downloadCLI(
    logOutput?: NodeJS.WritableStream,
  ): Promise<string> {
    if (!this.cliVersion) {
      throw new Error("cliVersion is not set")
    }

    const binPath = this.buildBinPath()

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Restore network access or configure a proxy/mirror so the pinned CLI can download.
  2. Verify the binary at the reported PATH exists, is executable, and runs (`<path> version`).
  3. Remove the stale cached CLI directory (e.g. under ~/.cache/dagger or ~/.dagger) to force a clean download.
  4. Pin a valid _default.cliVersion / pass an explicit version so the download target exists for your platform.

Example fix

// before (broken PATH binary + offline)
//   downloadError: getaddrinfo ENOTFOUND dagger.hn
//   failed to use CLI from PATH "/usr/local/bin/dagger": exec format error

// after
// $ rm -rf ~/.cache/dagger && export HTTPS_PROXY=http://proxy:8080 && retry connect()
Defensive patterns

Strategy: fallback

Validate before calling

import { execFile } from "child_process"
function canRunCli(binPath: string): Promise<boolean> {
  return new Promise((res) =>
    execFile(binPath, ["version"], (err) => res(!err)))
}
// check before connect(): if (!await canRunCli("/usr/local/bin/dagger")) fix install first

Try / catch

try {
  await dagger.connect()
} catch (e) {
  if (e instanceof AggregateError) {
    // e.errors[0] = download failure, e.errors[1] = PATH session failure
    for (const err of e.errors) console.error(err)
  }
  throw e
}

Prevention

When it happens

Trigger: No network access (download fails) AND the binary at this.binPath found on PATH is missing, incompatible, or fails to start an engine session. Connect() attempts both provisioning strategies and both must have failed.

Common situations: Air-gapped/CI environments without internet; a dagger binary on PATH of the wrong version or not executable; corrupted cache dir containing a broken binary.

Related errors


AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05). Data as JSON: /api/errors/a50d8724e49f4def. Report an issue: GitHub.