How To Install Rust in Linux
Created
Modified
Running the following in your terminal
If you’re running macOS, Linux, or another Unix-like OS. To download Rustup and install Rust, run the following in your terminal, then follow the on-screen instructions.
curl
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Rust is installed now. Great! To get started you may need to restart your current shell. This would reload your PATH environment variable to include Cargo's bin directory ($HOME/.cargo/bin). To configure your current shell, run: source $HOME/.cargo/env
To configure your current shell, run:
Rust
source ~/.profile
source ~/.cargo/env
rustc --version
cargo --version
rustc 1.60.0 (7737e0b5c 2022-04-04) cargo 1.60.0 (d1fd9fe 2022-03-01)
When you install Rustup you’ll also get the latest stable version of the Rust build tool and package manager, also known as Cargo.
On Windows, download and run rustup-init.exe.
Standalone installers
The official Rust standalone installers contain a single release of Rust, and are suitable for offline installation. See: https://forge.rust-lang.org/infra/other-installation-methods.html
Try Rust Online
You can try Rust online in the Rust Playground without installing anything on your computer. See: TRY RUST WITHOUT INSTALLING
Rustc Help Commands and Options
Usage: rustc [OPTIONS] INPUT
OPTIONS:
-h, --helpDisplay this message--cfg SPECConfigure the compilation environment-L [KIND=]PATHAdd a directory to the library search path. The optional KIND can be one of dependency, crate, native, framework, or all (the default).-l [KIND[:MODIFIERS]=]NAME[:RENAME]Link the generated crate(s) to the specified native library NAME. The optional KIND can be one of static, framework, or dylib (the default). Optional comma separated MODIFIERS (bundle|verbatim|whole-archive|as-needed) may be specified each with a prefix of either '+' to enable or '-' to disable.--crate-type [bin|lib|rlib|dylib|cdylib|staticlib|proc-macro]Comma separated list of types of crates for the compiler to emit--crate-name NAMESpecify the name of the crate being built--edition 2015|2018|2021Specify which edition of the compiler to use when compiling code.--emit [asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir]Comma separated list of types of output for the compiler to emit--print [crate-name|file-names|sysroot|target-libdir|cfg|target-list|target-cpus|target-features|relocation-models|code-models|tls-models|target-spec-json|native-static-libs|stack-protector-strategies|link-args]Compiler information to print on stdout-gEquivalent to -C debuginfo=2-OEquivalent to -C opt-level=2-o FILENAMEWrite output to filename--out-dir DIRWrite output to compiler-chosen filename in dir--explain OPTProvide a detailed explanation of an error message--testBuild a test harness--target TARGET Target triple for which the code is compiled-A, --allow LINTSet lint allowed-W, --warn LINTSet lint warnings--force-warn LINTSet lint force-warn-D, --deny LINTSet lint denied-F, --forbid LINTSet lint forbidden--cap-lints LEVELSet the most restrictive lint level. More restrictive lints are capped at this level-C, --codegen OPT[=VALUE]Set a codegen option-V, --versionPrint version info and exit-v, --verboseUse verbose output
Cargo Help Commands and Options
Rust's package manager
USAGE:
cargo [+toolchain] [OPTIONS] [SUBCOMMAND]
OPTIONS:
-V, --versionPrint version info and exit--listList installed commands--explain <CODE>Run `rustc --explain CODE`-v, --verboseUse verbose output (-vv very verbose/build.rs output)-q, --quietDo not print cargo log messages--color <WHEN>Coloring: auto, always, never--frozenRequire Cargo.lock and cache are up to date--lockedRequire Cargo.lock is up to date--offlineRun without accessing the network--config <KEY=VALUE>Override a configuration value (unstable)-Z <FLAG>Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details-h, --helpPrint help information
Commands:
Some common cargo commands are (see all commands with --list):
build, bCompile the current packagecheck, cAnalyze the current package and report errors, but don't build object filescleanRemove the target directorydoc, dBuild this package's and its dependencies' documentationnewCreate a new cargo packageinitCreate a new cargo package in an existing directoryrun, rRun a binary or example of the local packagetest, tRun the testsbenchRun the benchmarksupdateUpdate dependencies listed in Cargo.locksearchSearch registry for cratespublisPackage and upload this package to the registryinstallInstall a Rust binary. Default location is $HOME/.cargo/binuninstallUninstall a Rust binarySee 'cargo help <command>' for more information on a specific command.