Skip to content

Cannot work offline #11074

Closed
Closed
@ijackson

Description

@ijackson

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.)

See also #9273 #8207 #11041.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cliArea: Command-line interface, option parsing, etc.A-configurationArea: cargo config files and env varsC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions