How can I install a rust module/package offline?

I'm trying to install ansible offline. The python module cryptography 3.4.8 is a dependency for ansible. After downloading all the python dependencies, cryptography said it needed the rust compiler. I installed rust offline, now the python cryptography package begins the install and switches to the rust compiler but now rust wants a package/module named "pyo3". I downloaded the pyo3 zip file from github, but now my question is how do I install it locally offline to resolve this dependency for rust?

Normally, you don't.

You shouldn't install the bare Rust compiler in isolation, you should use Rustup for installing a toolchain that also includes Cargo, the Rust package manager. It manages downloading dependencies automatically.

Please read the relevant documentation.

There isn't rustup offline.

You can use "cargo vendor" to download all dependencies when online, then copy to offline.


Those "offline" thingies are required to install Rust on machines without internet access. If you can download anything you have access to the internet. Try the normal toolchain which downloads required dependencies if not already downloaded and produce library files you've requested to the local file system.

1 Like

@mczgcy Thank you. How do I then install the packages offline after downloading them?

Copy the downloaded packages into a directory on the isolated box. cargo vendor will have output things to put in your cargo.config, something like

replace-with = 'vendored-sources'

directory = '/parent/dir/of/vendored/stuff'
1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.