google-gemini/gemini-cli · error

Download failed: HTTP ${response.status} ${response.statusTe

Error message

Download failed: HTTP ${response.status} ${response.statusText}

What it means

During downloadFile() (used to fetch the LiteRT-LM binary for Gemma local model routing), if the HTTP response from fetch() has a non-2xx status, the error includes the status code and status text. This surfaces server-side failures (404, 403, 500, etc.) with actionable diagnostic information rather than a generic download failure.

Source

Thrown at packages/cli/src/commands/gemma/setup.ts:79

    const bar = '█'.repeat(filled) + '░'.repeat(barWidth - filled);
    const pctStr = (pct * 100).toFixed(0).padStart(3);
    process.stderr.write(
      `\r  [${bar}] ${pctStr}% ${formatBytes(downloaded)} / ${formatBytes(total)}`,
    );
  } else {
    process.stderr.write(`\r  Downloaded ${formatBytes(downloaded)}`);
  }
}

async function downloadFile(url: string, destPath: string): Promise<void> {
  const tmpPath = destPath + '.downloading';
  if (fs.existsSync(tmpPath)) {
    fs.unlinkSync(tmpPath);
  }

  const response = await fetch(url, { redirect: 'follow' });
  if (!response.ok) {
    throw new Error(
      `Download failed: HTTP ${response.status} ${response.statusText}`,
    );
  }
  if (!response.body) {
    throw new Error('Download failed: No response body');
  }

  const contentLength = response.headers.get('content-length');
  const totalBytes = contentLength ? parseInt(contentLength, 10) : null;
  let downloadedBytes = 0;

  const fileStream = fs.createWriteStream(tmpPath);
  const reader = response.body.getReader();

  try {
    for (;;) {
      const { done, value } = await reader.read();
      if (done) break;

View on GitHub (pinned to 5024443c72)

Solutions

  1. Check the HTTP status: 404 likely means the platform binary isn't available — verify platform support in constants.ts.
  2. Verify network connectivity and proxy/firewall settings.
  3. Retry later if it's a transient server-side issue (5xx).
  4. For 403, check if the download requires authentication or has region restrictions.
Defensive patterns

Strategy: retry

Validate before calling

async function isDownloadUrlReachable(url: string): Promise<boolean> {
  try {
    const resp = await fetch(url, { method: 'HEAD' });
    return resp.ok;
  } catch {
    return false;
  }
}

// Before setup:
if (!(await isDownloadUrlReachable(binaryUrl))) {
  console.error('Binary download URL is not reachable.');
}

Try / catch

async function downloadWithRetry(url: string, dest: string, maxRetries = 3): Promise<void> {
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
    try {
      await downloadFile(url, dest);
      return;
    } catch (e) {
      if (e instanceof Error && e.message.includes('HTTP 5') && attempt < maxRetries) {
        await new Promise((r) => setTimeout(r, 1000 * attempt));
        continue;
      }
      throw e;
    }
  }
}

Prevention

When it happens

Trigger: The binary download URL returns a 404 (binary not published for the detected platform), 403 (access forbidden), 500/502/503 (server error or CDN outage), or any other non-OK HTTP status.

Common situations: The LiteRT-LM binary hasn't been released for the user's platform/arch yet; network proxy returning an error page; CDN or hosting server outage; URL format changed in a new release; redirect chain ends at an error page.

Related errors


AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12). Data as JSON: /api/errors/cdf276d031757db5. Report an issue: GitHub.