Why Cargo stalls on remote Mac CI
Three constraints show up again and again:
- Index and crate latency. Sparse index calls multiply across the dependency graph. One slow hop to
index.crates.ioor a distant mirror amplifies wall time. - Flaky TLS and proxies. Corporate egress and MITM appliances break certificate chains unless you wire
CARGO_HTTP_CAINFOand proxy CA bundles explicitly. - Lockfile drift. Switching registry endpoints without a committed
Cargo.lockinvites silent graph changes. Binary crates should treat the lockfile as part of the supply-chain contract.
Selection decision matrix: mirrors, retries, lockfile
Use this table before you change infrastructure. It balances speed, auditability, and reproducibility for 2026 remote Mac builds.
| Option | When to choose | Trade-off | Lockfile rule |
|---|---|---|---|
Upstream sparse index (index.crates.io) |
Low latency to crates.io CDN; strict compliance prefers official endpoints | Cross-border links may need longer timeouts and higher CARGO_NET_RETRY |
Commit Cargo.lock; use cargo build --locked in CI |
Regional mirror (e.g. mirrors.ustc.edu.cn style index, or org-internal registry) |
Builders sit far from default CDN; you need predictable pull time | Mirror freshness and audit scope differ from upstream; document the URL | Same lockfile; fail CI if mirror lacks a pinned version |
| Vendor or git submodules | Air-gapped or policy forbids runtime registry access | More repo size and merge friction | Pin exact revisions; align with cargo vendor layout |
Example user-level config for a named mirror source (adjust host to your approved mirror):
[source.crates-io] replace-with = 'mirror' [source.mirror] registry = "sparse+https://your-registry-mirror.example.com/index/"
Remote Mac CI: three-step configuration
Keep remote Mac runners boring and repeatable. Expand each step into your pipeline jobs as needed.
CARGO_HOME. Install a fixed toolchain with rustup. Persist ~/.cargo/registry and ~/.cargo/git between runs so cold starts shrink.
CARGO_NET_RETRY=6, CARGO_HTTP_TIMEOUT=600 (seconds, per Cargo book mapping). Add HTTPS_PROXY when the Mac exits through a corporate proxy.
cargo fetch --locked as an early step. Follow with cargo build --locked or cargo test --locked. Splitting fetch and compile surfaces network issues before compilation spends CPU.
CARGO_NET_GIT_FETCH_WITH_CLI=true so Cargo shells out to the system git client with your existing http.* config.
GitHub Actions style fragment (adapt secrets names):
env:
CARGO_NET_RETRY: "6"
CARGO_HTTP_TIMEOUT: "600"
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
HTTPS_PROXY: ${{ vars.HTTPS_PROXY }}
Timeout, certificate, and proxy FAQ
Timeouts. Combine higher CARGO_HTTP_TIMEOUT with CARGO_NET_RETRY. For stall detection on thin links, CARGO_HTTP_LOW_SPEED_LIMIT and CARGO_HTTP_LOW_SPEED_TIME mirror curl semantics.
Certificates. Point CARGO_HTTP_CAINFO at a PEM file that includes your enterprise root. For proxies that re-sign TLS, add CARGO_HTTP_PROXY_CAINFO. Treat CARGO_HTTP_CHECK_REVOKE=false as a last resort with security sign-off.
Proxies. Cargo honors HTTPS_PROXY and CARGO_HTTP_PROXY. Align lowercase and uppercase variants with other tools on the same Mac. See also pull stability FAQ for shared retry thinking across Git and package managers.
Git submodules and monorepo coexistence
Workspace roots and nested git directories confuse paths. Run CI from the workspace manifest directory. Submodule crates should use path or git dependencies consistently; avoid mixing a submodule path with a registry version of the same crate.
For large monorepos, scope with cargo build -p crate_name --locked. Share one .cargo/config.toml at the repo root so every member sees the same mirror and net settings. If you vendor, commit the vendor tree only when policy requires it and document update cadence.
Quick reference you can paste
CARGO_NET_RETRYmaps tonet.retryin Cargo config; raise it before you re-architect mirrors.- Sparse index URLs commonly start with
sparse+https://; legacy git-style indices still exist on some mirrors—verify your vendor docs. - Binary products: always commit
Cargo.lock. Libraries: follow Rust ecosystem guidance for whether the lockfile belongs in VCS for your consumers.
Summary
Pick upstream versus mirror with the matrix, then enforce timeouts, retries, and --locked workflows on your remote Mac. Wire TLS and proxy variables once per machine image. When you need Apple Silicon close to your users, browse pricing and purchase on MacPull—no login required to view plans or node details. Help covers access and setup.
Remote Mac for Rust CI in 2026
Dedicated Mac Mini nodes for Cargo cache, SSH, and repeatable builds. View plans and purchase without logging in, or read the help center for node and access details.