Skip to content

crates.io fetches fail with HTTP 403 due to missing User-Agent in default wget FETCHCMD #3848

@billmcilhargey

Description

@billmcilhargey

Summary

Builds that fetch Rust crates via the crate:// fetcher (e.g. healthdog, fatrw, and any other Rust-based recipe) fail during do_fetch because crates.io now returns HTTP 403 to requests that do not include a User-Agent header. BitBake's default FETCHCMD:wget does not set one, so every crate download fails with wget exit code 8.

Affected branches / layers

  • meta-balena-common (kirkstone, and any other release using the crate fetcher with stock BitBake wget defaults)
  • Reproduced on meta-balena-kirkstone with DISTRO_VERSION = "6.12.2", MACHINE genericx86-64.

Reproduction

MACHINE=genericx86-64 bitbake balena-image-flasher

Fails with:

WARNING: healthdog-1.0.6-r0 do_fetch: Failed to fetch URL crate://crates.io/bitflags/1.2.1, attempting MIRRORS if available
ERROR: healthdog-1.0.6-r0 do_fetch: Fetcher failure: Fetch command ... wget -t 2 -T 100 -O .../bitflags-1.2.1.crate.tmp ... 'https://crates.io/api/v1/crates/bitflags/1.2.1/download' --progress=dot -v failed with exit code 8, no output
ERROR: healthdog-1.0.6-r0 do_fetch: Bitbake Fetcher Error: FetchError('Unable to fetch URL from any source.', 'crate://crates.io/bitflags/1.2.1')

ERROR: fatrw-0.2.21-r0 do_fetch: ... crate://crates.io/anyhow/1.0.62 ... exit code 8

Root cause

crates.io rejects requests without a recognizable User-Agent. Verified directly:

$ curl -sI 'https://crates.io/api/v1/crates/bitflags/1.2.1/download'
HTTP/2 403

$ curl -sI -A 'wget/1.21' 'https://crates.io/api/v1/crates/bitflags/1.2.1/download'
HTTP/2 302
location: https://static.crates.io/crates/bitflags/bitflags-1.2.1.crate

BitBake's wget invocation (/usr/bin/env wget -t 2 -T 100 -O ... --progress=dot -v) sends no User-Agent, which is why exit code 8 (server error response) is returned and there is "no output".

Proposed fix

Set a User-Agent for the wget fetcher at the distro level so all wget-based fetches (including the crate:// fetcher, which delegates to wget) work against crates.io and other servers that filter on UA.

In meta-balena-common/conf/distro/include/balena-os.inc:

# crates.io rejects requests without a User-Agent (HTTP 403). BitBake's default
# wget FETCHCMD does not set one, breaking Rust crate fetches.
FETCHCMD:wget = "/usr/bin/env wget -t 2 -T 100 --user-agent=balena-yocto-build --progress=dot -v"

Workaround

Add the same line to build/conf/local.conf until a fix lands.

Additional notes

  • Same failure will affect every other Rust recipe (e.g. anything pulling crates such as aho-corasick, anyhow, etc.) — the listed two recipes are just the first to be scheduled.
  • A more upstream-friendly alternative is to fix this in oe-core / BitBake itself, but a distro-level override unblocks balenaOS builds immediately.
    Continued with Autopilot: Task not yet completeProvided a copy-paste-ready GitHub issue title and description documenting the crates.io HTTP 403 failure caused by missing User-Agent in BitBake's default wget FETCHCMD, including reproduction steps, root cause verification, and the proposed distro-level fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions