dbt-labs/dbt-core · error · RuntimeError

failed to download {url}: {last}

Error message

failed to download {url}: {last}

What it means

`_fetch` downloads the prebuilt wheel from the manifest's `base_url` with up to `_RETRIES` (4) attempts and exponential backoff. If every attempt fails with URLError, TimeoutError, or OSError, it raises RuntimeError including the URL and the last exception. It exists because the sdist ships no code — the wheel must be fetched at install time.

Source

Thrown at crates/dbt-ci/templates/sdist_build_backend.py:92

            tty.write(text + "\n\n\n")
    except (OSError, ValueError):
        pass


def _fetch(url):
    last = None
    for attempt in range(1, _RETRIES + 1):
        try:
            req = urllib.request.Request(
                url, headers={"User-Agent": "{}-sdist".format(_MANIFEST["name"])}
            )
            with urllib.request.urlopen(req, timeout=_TIMEOUT) as resp:
                return resp.read()
        except (urllib.error.URLError, TimeoutError, OSError) as exc:
            last = exc
            if attempt < _RETRIES:
                time.sleep(2 ** (attempt - 1))
    raise RuntimeError(f"failed to download {url}: {last}")


def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
    _emit_notice()
    entry = _select_wheel()
    filename = entry["filename"]
    url = "{base}/{file}".format(base=_MANIFEST["base_url"].rstrip("/"), file=filename)
    data = _fetch(url)

    digest = hashlib.sha256(data).hexdigest()
    if digest != entry["sha256"]:
        raise RuntimeError(
            f"sha256 mismatch for {filename}: expected {entry['sha256']}, got {digest}"
        )

    out = Path(wheel_directory) / filename
    out.write_bytes(data)
    return filename

View on GitHub (pinned to 0267ce9170)

Solutions

  1. Check network connectivity and proxy settings (HTTPS_PROXY/HTTP_PROXY) in the install environment
  2. Verify the URL from the error message is reachable (curl it) — if 404, the release asset is missing
  3. Retry the install later if it's a transient CDN/network outage
  4. Pre-download the wheel and install it directly, or use a mirror of the release assets
  5. Use a release version whose assets are confirmed published

Example fix

# before (no egress in CI)
pip install mypkg
# after
export HTTPS_PROXY=http://proxy.corp:3128
pip install mypkg
Defensive patterns

Strategy: retry

Validate before calling

import urllib.request
def url_reachable(url: str) -> bool:
    try:
        return urllib.request.urlopen(url, timeout=10).status == 200
    except Exception:
        return False
# check base_url + filename before installing

Try / catch

try:
    build_wheel(wheel_dir)
except RuntimeError as e:
    if 'failed to download' in str(e):
        time.sleep(30)
        build_wheel(wheel_dir)  # retry once on transient network failure
    else:
        raise

Prevention

When it happens

Trigger: `build_wheel` (via `_fetch`) cannot download `{base_url}/{filename}`: DNS failure, no network, proxy/firewall blocking, HTTP 4xx/5xx surfacing as URLError (e.g. HTTPError), asset missing from the release store, or all attempts timing out after 60s each.

Common situations: CI runners without internet egress or behind a corporate proxy; the release asset was deleted or never uploaded; transient registry/CDN outage exhausting the 4 retries; TLS interception producing SSL errors.

Related errors


AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07). Data as JSON: /api/errors/369d8f35054e5237. Report an issue: GitHub.