charmcraft + Launchpad + Rust + Ubuntu lunar = weird download failures

Do you build your charms using Launchpad charm recipes? Are you building for Ubuntu 23.04 (lunar)? Do your charms have any Rust dependencies (directly or indirectly)? Do you see something like this in your build logs?

::             cargo build --manifest-path Cargo.toml --message-format=json-render-diagnostics --release -v --no-default-features --locked
::                 Updating crates.io index
::              Downloading crates ...
::             error: failed to download from `https://crates.io/api/v1/crates/zip/0.6.6/download`
::
::             Caused by:
::               [2] Failed initialization ([CONN-1-0] send: no filter connected)

If all of the above conditions are true, then you don’t need to ask us to open a firewall hole to crates.io or anything like that, even though it looks very much as if you might need to do so. In fact, you’ve run into rust-lang/cargo#12202. Add this to the relevant part in your charm to work around the problem:

build-environment:
  - CARGO_HTTP_MULTIPLEXING: "false"

Thanks to Corey Bryant for this fascinating puzzle and for testing the workaround.

2 Likes