Currently, the easiest way to get up and running with Rust is to run the following command in your shell:
curl -s https://static.rust-lang.org/rustup.sh | sudo sh
This will install Rust into /usr/local
and you usually need root
permissions to do that. I had been looking for an alternative for two
reasons:
- On my Macbook,
/usr/local
is mostly managed by Homebrew andbrew doctor
complains if it finds libraries that were put there by someone else. - I don’t have root permissions at the university computer lab.
Fortunately, installing Rust into $HOME
is relatively painless.
rustup.sh
lets you specify a custom prefix. The above command only has
to be slightly tweaked:
curl -s https://static.rust-lang.org/rustup.sh | sh -s -- --prefix=$HOME/.local
Once Rust has been installed, there’s still three things left to do.
- Put
rustc
etc. on your $PATH. - Tell
rustc
where to find the Rust libraries. - Tell
man
where to find the manual pages.
The first two points can be accomplished by adding the following to your
$HOME/.bashrc
or $HOME/.zshrc
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
Note: Take a look at lines 5 to 8. You should check whether either of these two directories actually exists. If not, you have to modify those lines accordingly.
If you are using fish, put this into
$HOME/.config/fish/config.fish
instead:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Now we need to tell man
where to find the manual pages. Add the
following line to $HOME/.manpath
:
MANPATH_MAP /Users/martin/.local/bin /Users/martin/.local/share/man
Finally, start a new terminal session and try the following:
rustc --version
man rustc
If you later want to upgrade to the latest nightly, just rerun
rustup.sh
(like above):
curl -s https://static.rust-lang.org/rustup.sh | sh -s -- --prefix=$HOME/.local