4 ms·
Love Rust. That said, I have not figured out the following, and I'm sure that there has to be a canonical solution for this: I have a Rust application that dep
by corndoge 10y ago
Love Rust. That said, I have not figured out the following, and I'm sure that there has to be a canonical solution for this:
I have a Rust application that depends on 1 crate from crates.io. I want to build it on an embedded device over serial that has no networking capabilities. Does Cargo have an 'offline mode' or something that I can use to say "I don't want to depend on the Internet to build this, just fetch this version of the crate and keep it?" Because I have not been able to find anything like that. I'm sure there's a good solution for it because Rust is billed as a systems language.
- steveklabnik 10y agohttp://doc.crates.io/faq.html#how-can-cargo-work-offline http://doc.crates.io/faq.html#how-can-cargo-work-offline is a TL;DR. You'll possibly also want to look at https://github.com/alexcrichton/cargo-vendor https://github.com/alexcrichton/cargo-vendor and https://github.com/alexcrichton/cargo-local-registry https://github.com/alexcrichton/cargo-local-registry
- corndoge 10y agoI read the first and last link, had not seen the second. Looks like what I need, thank you. Surprised that Rust seems to expect people to have Internet access to build.
- steveklabnik 10y agoAs the FAQ says, it only expects it when it needs to get something from the internet, which is a pretty reasonable default. I am biased, though ;)
- flukus 10y agoIs this similar to nuget, if your familiar with that? Ie, do you have "pinned" versions in a project and only need to access the internet when a package is missing?
- steveklabnik 10y agoI haven't used nuget a whole ton, but yes, that sounds like it. Basically, you have two files: Cargo.toml and Cargo.lock. The toml file declares what version ranges you want to use, then after a successful build, the exact versions used were put into the lockfile. After that, nothing will hit the network or change up versions until you either modify the version ranges in the toml file or use the command-line interface to ask to upgrade.
- codys 10y agoIn that case, it may also make sense to consider using the cross compilation capabilities in rust rather than building on the actual device.
- corndoge 10y agoYes, I considered cross compiling. However I have run into this problem often enough to want a real offline solution and to me it is simply unacceptable for a systems language to depend the Internet for builds involving external packages.
- codys 10y agoSure, I don't think the two are incompatible. One could want to cross compile and not want to require internet access.
- nonsince 10y agoFork it as a submodule in your repository, then change the Cargo.toml to point to the path by using [dependencies.somepackage] path = "./somepackage" Sorted.
- corndoge 10y agoAwesome, thank you!!