Developing with rust offline

Hi there!

First: I'm quite new to rust.

My Situation: I'm working and developing on a Windows machine but it has no access to Internet. I can go to a Linux machine and download things, copy them on USB Stick and then copy again from stick to the Windows machine.

I would like to start a rust Project, I downloaded and installed the rust 1.14 toolchain on the Windows machine.

I tested a "hello world", created and built the project with cargo, everything works fine.

Now I want to use serial = "0.3.4" crate in my project.

Ok, I could clone the serial and dependencies crates to Linux machine. I can copy the project to the USB stick. But then.....

... I have no idea where to copy on my Windows machine and how to get cargo to run without Internet Access.

Anyone can help please???

I'm really interested in rust but I need a real hardware project for my motivation!

Thanks, Mark


I think the easiest solution would be to develop on your Linux machine directly, so you don't need to copy things around; second best is probably to get Internet access on your Windows machine.

As a last resort, the data that you need to copy is in ~/.cargo (for the registry of crates) as well as in the "target" folder of your project (for the crates themselves). Of course to fill the "target" folder you'd have to compile your project first; which kind of brings us back to my initial suggestion :slight_smile:

You might want to look into cargo-vendor:

I unfortunately have not used it myself, so I can't be more specific :frowning:

1 Like

@matt2xu actually there is no way to connect the Windows to Internet. I can develop some code under Linux but after a certain point I need to connect to real Hardware. This is only at the Windows machine possible.

@matklad Ok, looks interesting and new to me. Do I understand it right:
1.) on Linux: cargo install cargo-vendor
2.) on Linux: setup my rust-project
3.) on Linux inside my project: cargo vendor
4.) copy my whole project and the vendored sources to Windows
5.) on Windows: change .cargo/config as described in the cargo-vendor example
6.) on Windows: cargo run

I will try it I can access the Linux, tomorrow the Windows.

If I've understood the process wrong, thanks for any hint in advance.

This looks reasonable, yeah, but I haven't tried cargo-vendor myself, so I can't be sure :slight_smile:

What about thought havent used it says it can mirror the whole crates and maybe serve it up locally?

@tyoc213 Maybe cargo cacher would help to download all the crates on my Linux machine but isn't there an easier way just to download all (e.g. as zip)? Maybe I will try with cargo cacher just to see how many MBytes all crates together fill on my hdd...

@matklad Great! It works! Seems to be a really cool workflow to use rust in 'offline' situations.
By the way: Personally I think a programming language that insists always on Internet isn't universal enough.
Thanks for help and special thanks to Alex Crichton! I really don't know his motivation to write cargo-vendor but it is exactly what I need.

1 Like

if you test how many mb it uses on drive plz let us know :slight_smile: