{"record":{"id":"a50d8724e49f4def","repo":"dagger/dagger","slug":"downloaderror-message-nfailed-to-use-cli-from-p","errorCode":null,"errorMessage":"${downloadError.message}\\nfailed to use CLI from PATH \"${this.binPath}\": ${sessionError.message}","messagePattern":"(.+?)\\\\nfailed to use CLI from PATH \"(.+?)\": (.+?)","errorType":"exception","errorClass":"AggregateError","httpStatus":null,"severity":"critical","filePath":"sdk/typescript/src/provisioning/bin.ts","lineNumber":84,"sourceCode":"\n  async Connect(opts: ConnectOpts): Promise<GraphQLClient> {\n    let downloadError: Error | undefined\n\n    if (!this.binPath) {\n      try {\n        this.binPath = await this.downloadCLI(opts.LogOutput)\n      } catch (e) {\n        downloadError = e instanceof Error ? e : new Error(String(e))\n        this.binPath = this.fallbackToLocalCLI(downloadError, opts.LogOutput)\n      }\n    }\n\n    try {\n      return await this.runEngineSession(this.binPath, opts)\n    } catch (e) {\n      if (downloadError) {\n        const sessionError = e instanceof Error ? e : new Error(String(e))\n        throw new AggregateError(\n          [downloadError, sessionError],\n          `${downloadError.message}\\nfailed to use CLI from PATH \"${this.binPath}\": ${sessionError.message}`,\n          { cause: e },\n        )\n      }\n      throw e\n    }\n  }\n\n  private async downloadCLI(\n    logOutput?: NodeJS.WritableStream,\n  ): Promise<string> {\n    if (!this.cliVersion) {\n      throw new Error(\"cliVersion is not set\")\n    }\n\n    const binPath = this.buildBinPath()\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/sdk/typescript/src/provisioning/bin.ts#L66-L102","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Restore network access or configure a proxy/mirror so the pinned CLI can download.","Verify the binary at the reported PATH exists, is executable, and runs (`<path> version`).","Remove the stale cached CLI directory (e.g. under ~/.cache/dagger or ~/.dagger) to force a clean download.","Pin a valid _default.cliVersion / pass an explicit version so the download target exists for your platform."],"exampleFix":"// before (broken PATH binary + offline)\n//   downloadError: getaddrinfo ENOTFOUND dagger.hn\n//   failed to use CLI from PATH \"/usr/local/bin/dagger\": exec format error\n\n// after\n// $ rm -rf ~/.cache/dagger && export HTTPS_PROXY=http://proxy:8080 && retry connect()","handlingStrategy":"fallback","validationCode":"import { execFile } from \"child_process\"\nfunction canRunCli(binPath: string): Promise<boolean> {\n  return new Promise((res) =>\n    execFile(binPath, [\"version\"], (err) => res(!err)))\n}\n// check before connect(): if (!await canRunCli(\"/usr/local/bin/dagger\")) fix install first","typeGuard":null,"tryCatchPattern":"try {\n  await dagger.connect()\n} catch (e) {\n  if (e instanceof AggregateError) {\n    // e.errors[0] = download failure, e.errors[1] = PATH session failure\n    for (const err of e.errors) console.error(err)\n  }\n  throw e\n}","preventionTips":["Keep network access OR a working dagger on PATH — at least one provisioning path must work","Validate the cached/PATH binary with `dagger version` before connecting","Clear corrupted cache dirs; verify executable permissions"],"tags":["provisioning","cli","network","path"],"backgroundTag":"cli-download-and-session-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}