github/copilot-sdk · error · RuntimeError

Failed to download from

Error message

Failed to download from {url}: {last_exc}

What it means

_fetch_url_bytes performs HTTP downloads with bounded retries for transient errors. After exhausting _MAX_RETRIES attempts, it wraps the last exception in this RuntimeError identifying the URL that could not be downloaded.

Solutions

  1. Check network connectivity and proxy settings (HTTPS_PROXY/HTTP_PROXY).
  2. Retry later — transient GitHub/CDN outages resolve; the library already retries with exponential backoff.
  3. Manually download the asset and use COPILOT_CLI_PATH to point at a local binary.
  4. Increase reliability of CI by caching the runtime bundle between jobs.

Example fix

# before
$ python -m copilot  # behind corporate proxy, no env set
# after
$ export HTTPS_PROXY=http://proxy.corp.example:3128
$ python -m copilot
Defensive patterns

Strategy: retry

Validate before calling

import urllib.request
try:
    urllib.request.urlopen("https://github.com", timeout=5)
except OSError as e:
    raise SystemExit(f"network unavailable before download: {e}")

Try / catch

import time
for attempt in range(5):
    try:
        return download_cli()
    except RuntimeError as e:
        if "Failed to download" not in str(e) or attempt == 4:
            raise
        time.sleep(2 ** attempt)

Prevention

When it happens

Trigger: Any download of the checksum file or release package (via _fetch_checksums or _fetch_verified_release_package) that fails on every retry — DNS failure, connection reset, TLS error, timeouts, or persistent 5xx responses.

Common situations: Corporate proxies/firewalls blocking github.com downloads; offline or flaky CI networks; GitHub release CDN outages; very slow links exceeding the timeout.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09). Data as JSON: /api/errors/390ca5e00155fcef. Report an issue: GitHub.

Appendix: source

Thrown at python/copilot/_cli_download.py:248

            if cached is not None:
                return cached
        raise

    return str(binary_path)


def _fetch_url_bytes(url: str, *, timeout: int) -> bytes:
    """Download bytes from ``url`` with retries."""
    last_exc: Exception | None = None
    for attempt in range(_MAX_RETRIES):
        try:
            with urlopen(url, timeout=timeout) as response:
                return response.read()
        except _RETRIABLE_DOWNLOAD_ERRORS as exc:
            last_exc = exc
            if attempt < _MAX_RETRIES - 1:
                time.sleep(2**attempt)
    raise RuntimeError(f"Failed to download from {url}: {last_exc}") from last_exc


_HOSTLESS_EXCLUDED_TOP_LEVEL = {
    "app.js",
    "assets",
    "changelog.json",
    "copilot",
    "copilot.exe",
    "copilot-sdk",
    "foundry-local-sdk",
    "index.js",
    "LICENSE.md",
    "napi-oop-runtime",
    "npm-loader.js",
    "package.json",
    "preloads",
    "pvrecorder",
    "queries",

View on GitHub (pinned to cd8cf15dc3)