-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cargo metadata --offline requires Internet access #9273
Comments
Hi @Revantus, while the |
With the most recent update to Can you try these steps? These are what I used to try to replicate the issue on WLS and Windows native.
From what I'm seeing, Cargo is only unpacking the already downloaded and cached crates and not accessing the internet. |
It looks like the downstream worked around the problem with this change. That change lagged the published version I tested with to file the bug report. I retested with 0.5.0 and it is working offline 😃. Is this workaround the desired long term state for cargo? Note that they're using |
|
Re
I think this bug might be best scoped down to more of a UX issue [0]. In short, the real bug here is: when [0]: why scope down? I think there's a level of enhancement that is being requested here as well (local registries should enable all offline operations), but that is probably a feature request. |
Problem
Actual behavior: running
cargo metadata --offline
in a dependency of the primary crate tries to access the Internet. If the host has no access, this fails with a network error.Expected behavior:
cargo metadata --offline
does not attempt to access the Internet & returns a limited set of fields that can be calculated offline.Weird complicating factor: if the crate in question is vendored as a path dependency,
cargo metadata
works without the--offline switch
.Error example
Steps
C
that depends onwindows-rs
.cargo local-registry
to create a local registry forC
's dependencies.C
with the local registry replacingcrates.io
, and no Internet access. The build should fail with a cryptic error from thewindows-rs
build. To reproduce the error message I have above, modifying this line inside the local registry's copy ofwindows_winmd
crate. There is almost certainly a simpler repro, but I suspect an exact repro won't be strictly necessary to address this bug.Possible Solution(s)
When we make
windows-rs
a path dependency, it allowscargo metadata
to run in that crate without errors while offline. Whatever this code path is, can do the same thing in the local registry case? My suspicion is thatC
's lockfile somehow applies to thecargo metadata
command whenwindows-rs
is a path dependency.Notes
Output of
cargo version
:The text was updated successfully, but these errors were encountered: