Skip to content
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

cache crates index and downloaded crates for offline use #2654

Closed
llogiq opened this issue May 6, 2016 · 7 comments
Closed

cache crates index and downloaded crates for offline use #2654

llogiq opened this issue May 6, 2016 · 7 comments

Comments

@llogiq
Copy link
Contributor

llogiq commented May 6, 2016

Using cargo (from a nightly) while offline leads to a network error while updating the crates index. I think in general cargo should cache the index and downloaded crates to allow for automatic offline use – perhaps issue a warning, but continue running.

@diwic
Copy link

diwic commented May 6, 2016

Or perhaps we could add a --no-update-index switch or so that would just skip the "Updating registry" part and move on to the next part?

This would be helpful if you're offline, start a new project, and add build dependencies that are already downloaded (because you have other projects using them, so they already exist in ~/.cargo.

@hexsel
Copy link

hexsel commented May 6, 2016

Maven has a -o ("offline") switch which will do its best to run with the current versions (even on things that are "snapshots" - i.e. running builds) and fail early if it absolutely can't.

That may reverse some of the "stability of builds" though, but since it'd be explicit, it may be a reasonable price to pay.

@llogiq
Copy link
Contributor Author

llogiq commented May 6, 2016

I think the best solution would not require a command line switch (though adding one would certainly a good idea), but revert to offline usage if the package index cannot be reached and notify the user of this change. Also perhaps add some flag to the Cargo.lock that marks the dependencies as potentially outdated, so that cargo can remind the user to update once online.

@steveklabnik
Copy link
Member

As Alex said elsewhere:

To elaborate on this, Cargo precisely has a global cache of all crates and works offline. The precondition is that you must have fetched the crates from somewhere before you use them.

To guarantee that a project works offline, you should git clone the source code and then run cargo fetch to populate the cache. After this point if Cargo attempts to update the registry or download something then that's a bug and should be filed.

Can you reproduce the scenario where this happens?

@llogiq
Copy link
Contributor Author

llogiq commented May 6, 2016

Yes. And cargo fetch indeed works as advertised (though I need to be online for it to work).

@alexcrichton
Copy link
Member

Yes, as @steveklabnik quoted Cargo already implements what this issue is. I believe what you specifically are asking for is covered by #1882, so I'm going to close in favor of that.

@llogiq
Copy link
Contributor Author

llogiq commented May 6, 2016

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants