Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd the ability to ignore registry-lookup failures #1882
Comments
This comment has been minimized.
This comment has been minimized.
|
Do you know why Cargo decided to update the registry? Some possible cases could be that the lock file was missing or the lock file was present and a package was missing from the index. In both these cases it's kinda necessary to update the lockfile. Overall I agree that Cargo should be resilient to update failures, but I'd prefer to have something reproducible locally where it's 100% sure that Cargo doesn't need to update the registry, it's just optimistically doing so. |
This comment has been minimized.
This comment has been minimized.
|
Why is it impossible to update the lockfile if Cargo can't talk to the registry? |
This comment has been minimized.
This comment has been minimized.
|
It's certainly not impossible, there are situations where you can avoid talking to the registry, but many stars have to align:
All the error messages along the way, especially in resolution, would also need to indicate that allowing Cargo to talk to the registry might help make the errors go away. |
This comment has been minimized.
This comment has been minimized.
|
Having reasonable warning messages is certainly reasonable. However, it is really important that it is possible to do "as much as possible" while not being able to talk to the registry. This definitely includes a project not ending up in a state where it can't build without connecting back to the registry, which definitely happens right now. Ideally, Cargo would even be able to run |
This comment has been minimized.
This comment has been minimized.
|
Do you have an example of a state where cargo can't build without connecting back to the registry? The one I can think of is there's a lock file indicating that a version of a dependency is required but it isn't available locally, but I can't think of many others off the top of my head. |
This comment has been minimized.
This comment has been minimized.
|
Adding a dependency that you already have locally forces a registry update for sure. I seem to remember that offline |
This comment has been minimized.
This comment has been minimized.
|
A |
This comment has been minimized.
This comment has been minimized.
|
We discussed this on IRC a bit yesterday. Some conclusions were:
I think @sfackler's idea of an |
alexcrichton
referenced this issue
Nov 11, 2015
Closed
Enable Cargo to work without any network access #2111
aidanhs
referenced this issue
Nov 12, 2015
Closed
Cargo updating index even with lockfile presence #1710
This comment has been minimized.
This comment has been minimized.
lilydjwg
commented
Feb 14, 2016
|
(I hope I've found the most related issue to comment.) @alexcrichton I'd like to have an I've been offline for some days. I tried to write a simple program in those days, but Cargo always want to update its registry and thus failed. But I did have all my dependencies cached. I had to manually find and extract source files from cached crates, then manually call rustc with appropriate options, then build my little program. It was tedious. I want to write Rust programs just as I do with Python or C: when I have all necessary dependencies locally available, I can work with them; it only fails when I lack some of them. |
This comment has been minimized.
This comment has been minimized.
|
@lilydjwg this issue would indeed suffice for that use case! |
alexcrichton
referenced this issue
May 6, 2016
Closed
cache crates index and downloaded crates for offline use #2654
This comment has been minimized.
This comment has been minimized.
|
Another data point, while I'd welcome a |
This comment has been minimized.
This comment has been minimized.
MagaTailor
commented
May 14, 2016
•
|
Why does this need to go online? $ cargo clean -p rayon
Downloading clippy v0.0.64
error: unable to get packages from sourceA regular cargo clean doesn't require net access - what's going on? |
This comment has been minimized.
This comment has been minimized.
benaryorg
commented
Jul 21, 2016
This comment has been minimized.
This comment has been minimized.
oconnor663
commented
Sep 14, 2016
|
Another example use case for this stuff that I run into frequently: I like playing with Hello World examples when I'm trying out a new library, and I have a little shell function for creating them quickly. I frequently get myself in a state where one of my hello-world projects is building fine, but a new one with the same dependencies won't build without network access, probably because it's trying to create a lock file first. (Copying the lock file from the old project doesn't always seem to help, maybe because there's other metadata in there that I'd need to tweak and I just don't know enough to do it right.) I don't think solving my case wouldn't necessarily require adding flags. Maybe there could be a separate command (separate program entirely?) that knows how to inspect all my caches and then put my project in a state where it's guaranteed to build from those caches. I assume that Cargo's directory layout isn't stable, though, so it might make sense to have a tool like this inside the project? A tool like this might also be useful for people who want to set up their own vendoring, if they have a directory full of libraries and they want to rewrite their Cargo.toml to use all of them by path, though the inputs in that case are pretty different. |
This comment has been minimized.
This comment has been minimized.
Why do we need a special error message here? I think using cached deps from other apps can be viewed as an optimization. What about the following algo for adding a dependency?
|
This comment has been minimized.
This comment has been minimized.
|
At minimum I'd expect a warning if cargo has fallen back to trying to resolve using offline packages (though my personal preference is still to have a flag you need to use to opt in, per my comment on the other issue). |
This comment has been minimized.
This comment has been minimized.
|
@matklad yeah that's one possible route to take here, but it's subtly different enough that we need to be sure to tread lightly. That strategy would change Cargo's behavior around resolution, which runs the risk of causing lots of confusion down the line if you're not always getting the latest version of dependencies. (just something to keep in mind) |
This comment has been minimized.
This comment has been minimized.
caipre
commented
Oct 6, 2016
|
I ran into this last night when I found that the internet wasn't working at my home. No problem, I figured, since I happened to already have the packages I needed in my local cache. In fact, cargo insisted on updating the registry, even when my |
This comment has been minimized.
This comment has been minimized.
|
I would love ability to generate the Cargo.lock offline. I need to be able to add new dependencies to the project while working offline — I do have all the crates on my disk locally, especially when I split one of my crates in two. When I add a new dependency with |
This comment has been minimized.
This comment has been minimized.
FWIW this was a historical bug in Cargo which I believe was fixed recently. Does nightly Cargo exhibit this behavior for you? |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton Yes! I've tried again with the latest nightly and I was able to add a dependency offline. Great! |
matklad
referenced this issue
Mar 13, 2017
Closed
Allow to generate lockfile without registry update #3825
This comment has been minimized.
This comment has been minimized.
|
Closing in favor of #4686. While "airplane mode" doesn't have quite as nice a workflow, we feel it's the right place to start. |
brson commentedAug 8, 2015
I am constantly forced online because Cargo wants to update the registry. I do not like this and consider it a major problem that our build tool does not work without being connected to the Internet.
To give you a concrete example of a thing that happens. Earlier this week I built my project, cargo-crusader. Then I updated my toolchain, as I do nearly every day. Today I continued working on cargo-crusader while enjoying a morning in the refreshing air of a park. My peace was almost immediately disturbed when I discovered that I could no longer build cargo-crusader with the same crate resolution that worked just a few days ago because Cargo wanted to update the registry.