Offline dfx build

Noob question, is it possible to dfx build a Rust canister offline?

When I run the command I ran into an issue because it tries to download some advisory list from GitHub. Not sure if that’s a common Rust thing?

Checking for vulnerabilities in rust canisters.
Fetching advisory database from https://github.com/RustSec/advisory-db.git
error: couldn’t fetch advisory database: git operation failed: failed to resolve address for github.com: nodename nor servname provided, or not known; class=Net (12)
ERROR: Audit found vulnerabilities in rust canisters. Please address these problems as soon as possible!
Executing: cargo build --target wasm32-unknown-unknown --release -p satellite --locked

Cheers from a coffee shop with low mobile connection in Zürich :wink:

dfx appears to be calling out to cargo, so you could try doing that yourself temporarily and add the --frozen or --offline flag.

I think whether you have enough in you local cache will determine how successful that is.

You could also switch to a custom canister type and do that for your build command to keep using dfx build. That’s what I do for my Rust canisters but it’s not as straightforward.

3 Likes

Thanks! The --offline flag did the job :+1:

cargo build --target wasm32-unknown-unknown --release -p satellite --locked --offline
1 Like