Cannot work offline #11074
Labels
A-cli
Area: Command-line interface, option parsing, etc.
A-configuration
Area: cargo config files and env vars
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Problem
I am about to board a ferry from Wales to Ireland. On the ferry and for much of the rest of my trip, I will have no useful internet access. I am developing a proc macro crate. That crate's tests use
macrotest
, which in turn runscargo metadata
andcargo expand
.These commands access the internet. I can run
cargo --offline test
but that doesn't help, because the inner cargo invocations run online.As far as I can tell there is nothing sensible that the
cargo expand
crate, or themacrotest
crate, could do about this. They could support a custom environment variable to add to their cargo runs, but that seems like a bad idea.Proposed Solution
cargo should honour
CARGOFLAGS
. Then I could setCARGOFLAGS=--offline
.Additionally, cargo should honour
--no-locked
to overrideCARGOFLAGS=--offline --locked
. That way, I could setCARGOFLAGS=--offline --locked
and crates likemacrotest
that build little private projects could use--no-locked
to indicate that they need to regenerate the lockfile. (Ideally they would somehow have their deps represented in the toplevel lockfile but I suspect that is too hard wth the current architecture of cargo.)See also #9273 #8207 #11041.
In the meantime I am going to try putting a shell script wrapper called
cargo
on myPATH
, which will force offline mode. I don't know how this will interact with rustup's cargo wrapper. Badly I suspect :-/.Notes
No response
The text was updated successfully, but these errors were encountered: