I've been trying to get a windows installation on a flash drive for a while now.
-
First question: why?! Second: I don't think it's possible because you need the systems linker (ld.exe, ld, ld.gold,...)– hellowDec 26, 2018 at 7:17
-
Well, I want to bring it around with me to school and home and all that.– user10833948Dec 26, 2018 at 7:18
-
well, read the doc of rustup that simple.– StargateurDec 26, 2018 at 7:19
-
You can install it per user, you don't need admin privileges for that at all (expect for the mentioned linker)– hellowDec 26, 2018 at 7:20
-
@hellow Could you be able to shove a copy of GCC on the device and use it with the 32bit gnu copy? Or is that not a possibility– user10833948Dec 26, 2018 at 7:21
2 Answers
Since this question comes up first in the search engine when I searching for installing Rust on a pen drive. I'll answer it.
Installing on pen drive makes sense on Windows, if you want to carry the installation with you.
- Download rustup-init.exe from the official Rust page (you probably want the 64 bit one nowadays).
- set RUSTUP_HOME and CARGO_HOME environment variables to point to a location on your pen drive.
- When you start it will echo back these environment variables. To let you verify it.
- When asked tell it to customize install.
- I have portable MinGW on my pen drive so I have chosen x86_64-pc-windows-gnu as the host triplet to install.
- Tell it to not to alter your PATH, instead have a BAT script that you can start to set these vars for the shell.
I have a BAT script on the pen drive to ensure the PATHs are right despite what drive letter gets assigned, such as this:
set DRIVE=%CD:~0,2%
set MINGW_PATH=%DRIVE%\!\Mingw64\mingw64\bin
set GIT_PATH=%DRIVE%\!\PortableGit\cmd
set VSCODE_PATH=%DRIVE%\!\VSCode
set RUSTUP_HOME=%DRIVE%\!\Rust\rust
set CARGO_HOME=%DRIVE%\!\Rust\cargo
set RUST_PATH=%CARGO_HOME%\bin
And when you plug in the pen drive to a different computer, then after the install run this bat to have the paths.
Notice: note that this way can not use in ExFAT filesystem. Please see this issues
Something like https://www.codejam.info/2015/03/portable-rust-installation.html might work? Possibly with putting the profile script on the drive to be run after inserting? Also, is this for Linux, Windows or something else?
First, get the binaries according to your system, and the Rust version you want. For me (nightly 64-bit Linux binaries) and extract the archive (I like to put it in ~/opt):
wget https://static.rust-lang.org/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz tar xf rust-nightly-x86_64-unknown-linux-gnu.tar.gz mv rust-nightly-x86_64-unknown-linux-gnu rustThen, just export the appropriate environment variables (do this from your ~/.profile or equivalent to have it set up automatically). No need to install anything globally!
export LD_LIBRARY_PATH=~/opt/rust/rustc/lib:$LD_LIBRARY_PATH export PATH=~/opt/rust/rustc/bin:~/opt/rust/cargo/bin:$PATH
-
1Triple-quotes are a GitHub-flavored markdown extension. We don't support that variant here -- only four-space indents format multi-line blocks as code with syntax highlighting, full-line backdrop, &c. Dec 27, 2018 at 20:11
-
1BTW, you usually don't need to
export PATH=..., and certainly not more than once -- justPATH=...will change both environment and shell-internal instances of an already-exported variable. (LD_LIBRARY_PATHmay not be exported yet, so explicitly exporting that one is useful). Dec 27, 2018 at 20:12