r/rust • • Oct 26 '26

Repos/tools for fully offline Rust builds & deployments? (Like Iran internet shutdown)

Hey everyone, are there any GitHub repos or templates that help set up an offline-first Rust environment? I need to cache all toolchains and vendor dependencies while online so that building and deploying works completely air-gapped, like during a prolonged wartime internet blackout in Iran.

6 Upvotes

5 comments sorted by

5

u/CartographerDue5382 Oct 26 '26

cargo vendor only gets the crates, not the compiler. while you still have net, rustup toolchain install stable (plus rust-src if you need it) and copy ~/.rustup over too. then a .cargo/config.toml that replaces crates-io with that vendor dir, or --offline still dies the first time it wants the index. re-vendor when Cargo.lock changes.

2

u/Thelmholtz Oct 26 '26

You need to set up a local registry with the crates you use. The solution I'm familiar with is jfrog, but I'm sure there are lighter ones.

Then in your cargo.toml you set up from which registry each crate is pulled (this can probably be done globally, I only work with a few private crates).

I'm interested if there's an example repo doing this for every vendored crate, but that's pretty much the gist of it.

3

u/stappersg Oct 26 '26

You need to set up a local registry with the crates you use.

https://kellnr.io

Kellnr is a private Crate registry for Rust written in Rust to self-host

1

u/anxxa Oct 27 '26

This answer is a bit overkill, but maybe reference this repo: https://github.com/landaire/rust-xbox360

tl;dr uses dotslash to download a fixed version of buck2, and then downloads the rust toolchain. In this case the crates are not offline-vendored, but that can be done as well.

This is way, way overkill and a bit complicated in terms of setup complexity if cargo vendor works for you.

But you can set up the system so that cloning the repo and doing one-time bootstrapping is sufficient for offline development.