Setup a portable rust on Windows
✨ Created on 2024/5/2 ✨ Updated on 2024/9/26
Main Procedure
1. Download rust from the rust page.
For example:
https://static.rust-lang.org/dist/rust-1.77.2-x86_64-pc-windows-gnu.tar.gz
2. Extract the .tar.gz file.
For example:
set from=C:\rust-1.77.2-x86_64-pc-windows-gnu
3. Create a new folder for your portable rust.
For example:
mkdir C:\rust
set to=C:\rust
4. Copy the folders from extracted folder to target rust folder.
xcopy /e /y %from%\cargo\* %to%\
xcopy /e /y %from%\rustc\* %to%\
xcopy /e /y %from%\rust-mingw\* %to%\
xcopy /e /y %from%\rust-std-x86_64-pc-windows-gnu\* %to%\
rem (optional) rustfmt
xcopy /e /y %from%\rustfmt-preview\* %to%\
5. Add rust to path.
set path=%to%\bin;%path%
Additional Information
To solve the can't load standard library from sysroot
error of rust-analyzer.
1. Download source code of rust from the rust page.
For example:
https://static.rust-lang.org/dist/rustc-1.77.2-src.tar.xz
2. Create the folder
mkdir %to%\lib\rustlib\src