Description
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 runs cargo metadata
and cargo 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 the macrotest
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 set CARGOFLAGS=--offline
.
Additionally, cargo should honour --no-locked
to override CARGOFLAGS=--offline --locked
. That way, I could set CARGOFLAGS=--offline --locked
and crates like macrotest
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.)
In the meantime I am going to try putting a shell script wrapper called cargo
on my PATH
, which will force offline mode. I don't know how this will interact with rustup's cargo wrapper. Badly I suspect :-/.
Notes
No response