How to use rust crates in offline mode

899 Views Asked by At

Due to our company cyber security policy, I have to work in offline mode. (From offline, here I mean, internet can never be connected to the PC, the only option is to download source on some other PC and copy it to the target PC, where I am developing rust projects)

On experimental basis, I wanted to develop and run the guessing_game ( https://doc.rust-lang.org/book/ch02-00-guessing-game-tutorial.html).

I downloaded and copies the source code of the guessing_game to offline PC. I also downloaded and copied source code of rand crate (https://github.com/rust-random/rand) to my offline PC.

What are the steps to configure my PC such that it start pointing to the offline source of rand crates instead of going to the internet (As it is not connected to internet).

1

There are 1 best solutions below

4
On BEST ANSWER

You could try using cargo-local-registry. It allows you to make a local registry, that is, a mirror of crates.io with only the packages you're interested in. Then, when you build, cargo can be told to only fetch packages from there (no online connection requested).