rust development install(linux)
1. Rust and Cargo install
1.1 rust and cargo install text
1.1.1 command: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
1.1.2 examples: [root@rocky temp]# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
1 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 2 3 4 5 [root@rocky temp]# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 6 info: downloading installer 7 8 Welcome to Rust! 9 10 This will download and install the official compiler for the Rust 11 programming language, and its package manager, Cargo. 12 13 Rustup metadata and toolchains will be installed into the Rustup 14 home directory, located at: 15 16 /root/.rustup 17 18 This can be modified with the RUSTUP_HOME environment variable. 19 20 The Cargo home directory is located at: 21 22 /root/.cargo 23 24 This can be modified with the CARGO_HOME environment variable. 25 26 The cargo, rustc, rustup and other commands will be added to 27 Cargo's bin directory, located at: 28 29 /root/.cargo/bin 30 31 This path will then be added to your PATH environment variable by 32 modifying the profile files located at: 33 34 /root/.profile 35 /root/.bash_profile 36 /root/.bashrc 37 38 You can uninstall at any time with rustup self uninstall and 39 these changes will be reverted. 40 41 Current installation options: 42 43 44 default host triple: x86_64-unknown-linux-gnu 45 default toolchain: stable (default) 46 profile: default 47 modify PATH variable: yes 48 49 1) Proceed with installation (default) 50 2) Customize installation 51 3) Cancel installation 52 >1 53 54 info: profile set to 'default' 55 info: default host triple is x86_64-unknown-linux-gnu 56 warning: Updating existing toolchain, profile choice will be ignored 57 info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu' 58 info: default toolchain set to 'stable-x86_64-unknown-linux-gnu' 59 60 stable-x86_64-unknown-linux-gnu unchanged - rustc 1.65.0 (897e37553 2022-11-02) 61 62 63 Rust is installed now. Great! 64 65 To get started you may need to restart your current shell. 66 This would reload your PATH environment variable to include 67 Cargo's bin directory ($HOME/.cargo/bin). 68 69 To configure your current shell, run: 70 source "$HOME/.cargo/env" 71 [root@rocky temp]#
1.1.3 show images
1.2 configure environment of rust and cargo
1.2.1 vim /etc/profile
1.2.2 add "~/.cargo/bin" to $PATH of profile(/etc/profile)
1 [root@rocky temp]# cat /etc/profile 2 # /etc/profile 3 4 # System wide environment and startup programs, for login setup 5 # Functions and aliases go in /etc/bashrc 6 7 # It's NOT a good idea to change this file unless you know what you 8 # are doing. It's much better to create a custom.sh shell script in 9 # /etc/profile.d/ to make custom changes to your environment, as this 10 # will prevent the need for merging in future updates. 11 12 pathmunge () { 13 case ":${PATH}:" in 14 *:"$1":*) 15 ;; 16 *) 17 if [ "$2" = "after" ] ; then 18 PATH=$PATH:$1 19 else 20 PATH=$1:$PATH 21 fi 22 esac 23 } 24 25 26 if [ -x /usr/bin/id ]; then 27 if [ -z "$EUID" ]; then 28 # ksh workaround 29 EUID=`/usr/bin/id -u` 30 UID=`/usr/bin/id -ru` 31 fi 32 USER="`/usr/bin/id -un`" 33 LOGNAME=$USER 34 MAIL="/var/spool/mail/$USER" 35 fi 36 37 # Path manipulation 38 if [ "$EUID" = "0" ]; then 39 pathmunge /usr/sbin 40 pathmunge /usr/local/sbin 41 else 42 pathmunge /usr/local/sbin after 43 pathmunge /usr/sbin after 44 fi 45 46 HOSTNAME=$(/usr/bin/hostnamectl --transient 2>/dev/null) || \ 47 HOSTNAME=$(/usr/bin/hostname 2>/dev/null) || \ 48 HOSTNAME=$(/usr/bin/uname -n) 49 50 HISTSIZE=1000 51 if [ "$HISTCONTROL" = "ignorespace" ] ; then 52 export HISTCONTROL=ignoreboth 53 else 54 export HISTCONTROL=ignoredups 55 fi 56 57 export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL 58 59 for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do 60 if [ -r "$i" ]; then 61 if [ "${-#*i}" != "$-" ]; then 62 . "$i" 63 else 64 . "$i" >/dev/null 65 fi 66 fi 67 done 68 69 unset i 70 unset -f pathmunge 71 72 if [ -n "${BASH_VERSION-}" ] ; then 73 if [ -f /etc/bashrc ] ; then 74 # Bash login shells run only /etc/profile 75 # Bash non-login shells run only /etc/bashrc 76 # Check for double sourcing is done in /etc/bashrc. 77 . /etc/bashrc 78 fi 79 fi 80 81 82 # config by david 83 RUST_INSTALL=/root/.cargo/bin 84 USER_TOOLS=/root/user/tools 85 export JAVA_HOME=/usr/local/java/jdk1701 86 export CLASSPATH=.:$JAVA_HOME/lib 87 export PATH=$PATH:/$USER_TOOLS:$JAVA_HOME/bin:$RUST_INSTALL 88 [root@rocky temp]# 89 [root@rocky temp]# 90 [root@rocky temp]# source /etc/profile 91 [root@rocky temp]# 92 [root@rocky temp]# 93 [root@rocky temp]# rustc --version 94 rustc 1.65.0 (897e37553 2022-11-02) 95 [root@rocky temp]# 96 [root@rocky temp]#
2. reference
2.1 rust and cargo install: https://www.rust-lang.org/tools/install
2.2 configure environment of rust and cargo: https://www.rust-lang.org/tools/install
2.3 rust - docs all: https://www.rust-lang.org/learn
2.4 rust - help: https://doc.rust-lang.org/book/
2.5 cargo - help: https://doc.rust-lang.org/cargo/index.html
标签:development,profile,cargo,etc,install,bin,root,rust From: https://www.cnblogs.com/lnlidawei/p/16981765.html