Linux HOWTOs

About | Home | Search

HOWTO: rust
Description: A systems programming language
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything

# Rust 1.29.2
# ===========
# Info about installing Rust via rustup:
# Assuming you trust that the devlopers are not evildoers and the process
# will not mess anything up on your system...  The easiest, simplest way of
# installing it is by using rustup.  It can also keep it updated for you.
# curl -sSf | sh
# With rustup, programs go in ~/.cargo/bin
# It modifies ~/.profile to add that to PATH
# To uninstall a rustup-installed Rust: rustup self uninstall
# I installed it from source below to see how that goes, then removed
# that and used the rustup method instead (so I may not update this HOWTO
# again any time soon).  The process could be hours to compile it vs
# 1 minute to download and auto-install it.

# Below we cover installing it manually from source, but even then, you're
# running a Python script that downloads a tarball, then you maybe clone
# something with Git... so, far from manual

# Prerequisites:
# Python 2.7 (not 3.x)
# CMake >= 3.4.3
# curl
# Git

# See the Rust site for documentation, user forum, IRC, ...

# Here is some info about What is (used to build and install below):

# Get it
test -f installed/rustc-1.29.2-src.tar.gz &&
 mv -f installed/rustc-1.29.2-src.tar.gz .
test ! -f rustc-1.29.2-src.tar.gz &&

# Verify tarball w/ sha256sum:
# (this came from my gpg-verified tarball)
echo "5088e796aa2e47478cdf41e7243fc5443fafab0a7c70a11423e57c80c04167\
c9  rustc-1.29.2-src.tar.gz" | sha256sum -c

# Verify tarball w/ gpg:
( gpg --list-keys 7B3B09DC 2>&1 || gpg --recv-keys 7B3B09DC ) &&
 wget -nc &&
  gpg --verify rustc-1.29.2-src.tar.gz.asc &&
   rm -f rustc-1.29.2-src.tar.gz.asc

# Extract it
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "rustc-*-src" -exec rm -r {} \;
tar xzvf ~/rustc-1.29.2-src.tar.gz
cd rustc-1.29.2-src
test $UID = 0 && chown -R root:root .

# Build it
./ build

# To change installation paths, use config.toml (copy config.toml.example)
# If you are 64-bit and use /usr/local/lib64, edit the libdir line
# /usr/local/man, not /usr/local/share/man (may be a symlink...)
# /usr/local/info, not /usr/local/share/info (")
# Verify changes with 'diff -u config.toml.example config.toml'
test $(uname -m) = 'x86_64' &&
 cat config.toml.example | sed \
  -e 's/^#libdir = .*/libdir = "lib64"/' \
  -e 's/^#mandir = .*/mandir = "man"/' \
  -e 's/^#infodir = .*/infodir = "info"/' > config.toml

# Become root to install it

# Install it
./ install

## Some installation paths
# /usr/local/lib*/rustlib/
# /usr/local/bin/rust-gdb
# /usr/local/bin/rust-lldb
# /usr/local/bin/rustc
# /usr/local/bin/rustdoc

# Add the libraries directory to /etc/
egrep -q "^/usr/local/lib64/rustlib" /etc/ ||
 echo "/usr/local/lib64/rustlib/x86_64-unknown-linux-gnu/lib" >> \

# Make sure you can at least run this successfully
rustc --version

# Become yourself again

# Save the tarball for later
mkdir -p -m 0700 installed
rm -f installed/rustc-*-src.tar.*
mv rustc-1.29.2-src.tar.gz installed/

# Cargo (the Rust package manager)
# =====
# Python
# curl
# CMake
# OpenSSL headers
# rustc (hopefully installed above)

su -c "pip install pytoml dulwich requests"

cd /tmp
git clone
git clone
mkdir out

cd ~/src
test -d ./cargo && ( cd cargo ; git pull )
test ! -d ./cargo &&
 git clone --recursive
cd cargo
cp /tmp/cargo-bootstrap/ .
mkdir build
./ --crate-index /tmp/ --target-dir ./build \
 --no-clone --no-clean --target x86_64-unknown-linux
./configure --local-cargo=./build/cargo-0_5_0

test -d /tmp/cargo-bootstrap && rm -r /tmp/cargo-bootstrap
test -d /tmp/ && rm -r /tmp/

# If you ever want to uninstall Rust, this should do it:
test -x /usr/local/lib64/rustlib/ &&
for libdir in /usr/local/lib /usr/local/lib64;
  test -d $libdir && rm -r ${libdir}/rustlib
( cd /usr/local/bin ; rm -f rust-gdb rust-lldb rustc rustdoc )
find ~/src -maxdepth 1 -type d -name "rustc-*-src" -exec rm -r {} \;
rm -f ~/installed/rustc-*-src.tar.*

Back to the list

Last updated: Wed, 29 Apr 2020 22:04:50 -0400
Jason Englander <jason at englanders dot us>