What is cargo "Fetch"ing?

I have a workspace where, when I run cargo test, even with --offline, for a second or so I get a Fetch progress bar:

❯ cargo test --offline
     Fetch [==========================>      ] 0 complete; 0 pending             ^C

Oddly, if I run cargo fetch, I don't see this.

The help says:

           Prevents Cargo from accessing the network for any reason. [...]

So what's it doing?

(disclaimer: conjecture)

Your snippet does state 0 complete; 0 pending so it isn't doing any network fetches. I suspect it's just taking a moment to load the relevant information that would in the absence of --offline tell it what it needs to fetch. Is the workspace Cargo.lock significantly bigger than other workspaces that don't see this happen? (I assume it's workspace specific based on "I have a workspace where" implying others where it doesn't.)

Alternatively, if the fetch bar doesn't show up without --offline, it might be cargo building the offline registry which is used to serve what would otherwise be network requests during the compilation process. If offline mode is done by creating a mock network with known information, that could take some time.

CARGO_LOG variable might help you figure it out.

I think this is probably right, because I've seen the Fetch bar appear in normal, online, up-to-date operation when I was using a very slow machine (Chromebook).

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.