Martin Puppe

Installing Rust nightly builds into your home directory

Currently, the easiest way to get up and running with Rust is to run the following command in your shell:

curl -s | 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:

Fortunately, installing Rust into $HOME is relatively painless. lets you specify a custom prefix. The above command only has to be slightly tweaked:

curl -s | sh -s -- --prefix=$HOME/.local

Once Rust has been installed, there’s still three things left to do.

  1. Put rustc etc. on your $PATH.
  2. Tell rustc where to find the Rust libraries.
  3. 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:

if [ -d $HOME/".local/bin" ] ; then
    export PATH="$HOME/.local/bin:$PATH"

if [ ! -d $rust_dyld ] ;

if [ -d $rust_dyld ] ; then
    if [ -z $DYLD_LIBRARY_PATH ] ; then
        export DYLD_LIBRARY_PATH=$rust_dyld
        export DYLD_LIBRARY_PATH=$rust_dyld:$DYLD_LIBRARY_PATH

unset rust_dyld

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/ instead:

if test -d $HOME/.local/bin
    set -gx PATH $HOME/.local/bin $PATH

set -l rust_dyld $HOME/.local/lib/rustlib/x86_64-apple-darwin/lib
if test ! -d $rust_dyld
    set rust_dyld $HOME/.local/lib/rustlib/x86_64-unknown-linux-gnu/lib

if test -d $rust_dyld

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 (like above):

curl -s | sh -s -- --prefix=$HOME/.local