How can I work offline?
⚓ Rust 📅 2026-02-26 👤 surdeus 👁️ 2I'm at the mercy of an unreliable internet connection.
As well as a delay every time I execute cargo (since internet is slow), I also sometimes get this:
$ cargo --help --offline
info: syncing channel updates for 'nightly-2025-12-30-x86_64-unknown-linux-gnu'
error: failed to download file error=Reqwest(reqwest::Error { kind: Request, url
: "https://static.rust-lang.org/dist/2025-12-30/channel-rust-nightly.toml.sha256
", source: hyper_util::client::legacy::Error(Connect, ConnectError("dns error",
Custom { kind: Uncategorized, error: "failed to lookup address information: Name
or service not known" })) })
error: could not download file from 'https://static.rust-lang.org/dist/2025-12-3
0/channel-rust-nightly.toml.sha256' to '/home/alex/.rustup/tmp/8yekkyrk8frsedtd_
file': error downloading file: error sending request for url (https://static.rus
t-lang.org/dist/2025-12-30/channel-rust-nightly.toml.sha256): client error (Conn
ect): dns error: failed to lookup address information: Name or service not known
: failed to lookup address information: Name or service not known
I would prefer that running cargo with --offline mode would not access the net.
I would prefer to get cargo help without accessing the net.
I would prefer to use stable, but there are several features I'm using that are nightly only.
I have set up a rust-toolchain.toml pointing to a specific nightly, in the hope that using nightly wouldn't trigger internet access each time I use it.
I would prefer to be able to use a specific toolchain without it accessing the net every time.
I understand that if I want a new crate in my project, I'd need internet access to download that. But once it's downloaded, why can't I work offline until I need the next crate? If my internet is down, it can sometimes be troublesome to fix it, and being able to operate offline for an hour or two would be a huge usability improvement for me.
$ cat .cargo/config.toml
[target.x86-unknown-none]
rustflags = ["-C", "link-arg=-Tlink.x"]
[unstable]
build-std = ["core", "compiler_builtins", "alloc"]
[build]
target = "x86-unknown-none.json"
$ cat rust-toolchain.toml
[toolchain]
channel = "nightly-2025-12-30"
components = ["rustfmt", "clippy", "rust-src"]
targets = ["x86-unknown-none.json"]
For reference, with the internet working:
$ cargo -vv --help --locked --offline
info: syncing channel updates for 'nightly-2025-12-30-x86_64-unknown-linux-gnu'
info: latest update on 2025-12-30, rust version 1.94.0-nightly (56f24e00c 2025-1
2-29)
info: component 'clippy' for target 'x86_64-unknown-linux-gnu' is up to date
info: component 'rust-src' is up to date
info: component 'rustfmt' for target 'x86_64-unknown-linux-gnu' is up to date
warn: Force-skipping unavailable component 'rust-std-x86-unknown-none.json'
Rust's package manager
Usage: cargo [+toolchain] [OPTIONS] [COMMAND]
cargo [+toolchain] [OPTIONS] -Zscript <MANIFEST_RS> [ARGS]...
...
Any suggestions on how to configure things to work better would be appreciated.
I like cargo and it does make package management easy if you have reliable internet. But because of this and other problems (I'm having to use an external linker anyway because reasons,) perhaps the best thing is to ditch cargo and use some other build system.
3 posts - 2 participants
🏷️ Rust_feed