您好,登录后才能下订单哦!
这期内容当中小编将会给大家带来有关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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。