So I'm on a pretty airgapped system (Company Policy) and want to do an offline install of rust with the msvc toolchain. So far so good, i can install it, use cargo to create a new package and compile it but when I try to use vscode with rust-analyzer i get this error
can't load standard library from sysroot\n{sysroot_path}\n(discovered via `rustc --print sysroot`)\ntry installing the Rust source the same way you installed rustc
So my question is where do I download the rust-src component from and where do I put it on my System
it is not recommended to develop rust code on a airgapped machine, you might encounter various unexpected problems of rust-analyzer. one such example is #12499.
but anyway, you can find the urls for each individual component in the manifest.
I am aware but sadlyI have no influence over if it's airgapped or not, as it's company policy, and I'm tasked with setting up a rust dev environment on it
it is a toml file, you just open it with your text editor and search the component you wish to download. for example, the rust-src component can be found at this section:
as you can see, the rust-src component is target independent (.target."*") and there are urls for gzip and xz compressed tar balls. usually, xz should be preferred for better compression ratio, but if your system doesn't support xz, you can always use the gzip format.
download the tar ball of the component and extract it to a temporary location. you can either:
manually copy the content of the directory with the same name as the component (e.g. rust-src) to your rust installation location; or
run the install.sh script.
typically, you just need to specify the --destdir and/or --prefix at the command line. use --help to see the full list of supported options.
I just realized that the offline install doesn't include clippy or rustfmt. The manifest has download Paths for clippy-preview and rustfmt-preview, not for a normal, non preview version. where do i get those?
The internal names of the clippy and rustfmt components are clippy-preview and rustfmt-preview. Rustup does a renaming in the user facing ui. These components used to be unstable and we kept the -preview suffix in the internal name to avoid, once these components got stabilized, breaking updates of existing installations that have those components installed.
Each tar file contains a directory named after the component itself. You can copy the contents of this directory for each component into the same directory (merging the contents of subdirectories).
I tried both putting the rustfmt-preview directory into the rust directory and placing it directly in the program files directory but both result in
cargo fmt
error: no such command: `fmt`
Did you mean `fix`?
View all installed commands with `cargo --list`
Find a package to install `fmt` with `cargo search cargo-fmt`