您好,登錄后才能下訂單哦!
這期內容當中小編將會給大家帶來有關Linux系統中如何安裝Rust編程語言,文章內容豐富且以專業的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
我們可以通過多種方式安裝 Rust,但以下是官方推薦的安裝方式。
$ curl https://sh.rustup.rs -sSf | sh
輸入命令后控制臺輸出: root@node_super:~# curl https://sh.rustup.rs -sSf | sh info: downloading installer Welcome to Rust! This will download and install the official compiler for the Rust programming language, and its package manager, Cargo. It will add the cargo, rustc, rustup and other commands to Cargo's bin directory, located at: /root/.cargo/bin This can be modified with the CARGO_HOME environment variable. Rustup metadata and toolchains will be installed into the Rustup home directory, located at: /root/.rustup This can be modified with the RUSTUP_HOME environment variable. This path will then be added to your PATH environment variable by modifying the profile file located at: /root/.profile You can uninstall at any time with rustup self uninstall and these changes will be reverted. Current installation options: default host triple: x86_64-unknown-linux-gnu default toolchain: stable profile: default modify PATH variable: yes 1) Proceed with installation (default) 2) Customize installation 3) Cancel installation > info: profile set to 'default' info: default host triple is x86_64-unknown-linux-gnu info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu' 463.3 KiB / 463.3 KiB (100 %) 94.6 KiB/s in 2s ETA: 0s info: latest update on 2020-03-12, rust version 1.42.0 (b8cedc004 2020-03-09) info: downloading component 'cargo' 4.8 MiB / 4.8 MiB (100 %) 707.4 KiB/s in 7s ETA: 0s info: downloading component 'clippy' 1.8 MiB / 1.8 MiB (100 %) 887.5 KiB/s in 3s ETA: 0s info: downloading component 'rust-docs' 12.0 MiB / 12.0 MiB (100 %) 1.6 MiB/s in 9s ETA: 0s info: downloading component 'rust-std' 17.1 MiB / 17.1 MiB (100 %) 2.5 MiB/s in 8s ETA: 0s info: downloading component 'rustc' 58.6 MiB / 58.6 MiB (100 %) 3.4 MiB/s in 20s ETA: 0s info: downloading component 'rustfmt' 3.0 MiB / 3.0 MiB (100 %) 2.9 MiB/s in 1s ETA: 0s info: installing component 'cargo' info: installing component 'clippy' info: installing component 'rust-docs' 12.0 MiB / 12.0 MiB (100 %) 7.0 MiB/s in 1s ETA: 0s info: installing component 'rust-std' 17.1 MiB / 17.1 MiB (100 %) 10.5 MiB/s in 1s ETA: 0s info: installing component 'rustc' 58.6 MiB / 58.6 MiB (100 %) 8.8 MiB/s in 6s ETA: 0s info: installing component 'rustfmt' info: default toolchain set to 'stable' stable installed - rustc 1.42.0 (b8cedc004 2020-03-09) Rust is installed now. Great! To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH environment variable. Next time you log in this will be done automatically. To configure your current shell run source $HOME/.cargo/env
運行以下命令配置當前 shell。
$ source $HOME/.cargo/env
運行以下命令驗證已安裝的 Rust 版本。
$ rustc --version
安裝 Rust 后,請按照以下步驟檢查 Rust 語言是否正常工作。
mkdir /home/rust/ cd /home/rust/ vim test.rs
寫入如下代碼
fn main() { println!("Hello, welcome to come Rust!"); }
運行以下命令編譯 rust 代碼。
rustc test.rs
上面的命令將在同一目錄中創建一個可執行的 Rust 程序。
ls -lh
運行 Rust 可執行文件得到輸出。
./test Hello, welcome to come Rust!
將 Rust 更新到最新版本。
rustup update
運行以下命令從系統中刪除 Rust 包。
rustup self uninstall
Linux是一種免費使用和自由傳播的類UNIX操作系統,是一個基于POSIX的多用戶、多任務、支持多線程和多CPU的操作系統,使用Linux能運行主要的Unix工具軟件、應用程序和網絡協議。
上述就是小編為大家分享的Linux系統中如何安裝Rust編程語言了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關知識,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。