How do I build completely offline?

⚓ Rust    📅 2026-05-06    👤 surdeus    👁️ 1      

surdeus

Hi!

I can build a program (with external crate dependencies) with Cargo with internet connection, as it fetches said dependencies from crates.io. Passing --offline to cargo when doing so (after having built with internet connection) works fine, but as soon as ~/.cargo/registry/index/index.crates.io-xyz/.cache is deleted, the build fails with cannot locate crate 'crate' and it states that it looked in crates.io index. Even if I have the source for the dependencies in ~/.cargo/registry/src.

I'd like to be able to build it completely offline, and I don't see any reason why this can't happen if I've already got the sources.

How can I resolve the error so Cargo looks for the packages/sources locally rather than on crates.io?

Any help is greatly appreciated!

2 posts - 2 participants

Read full topic

🏷️ Rust_feed