用AI赚第一桶💰低成本搭建一套AI赚钱工具,源码可二开。 广告
[TOC] ### **环境安装** **** #### **在 Linux 或 macOS 上安装`rustup`** 如果你使用 Linux 或 macOS,打开终端并输入如下命令: ``` $ curl https://sh.rustup.rs -sSf | sh ``` 或者使用命令: ``` $ curl -f -L https://static.rust-lang.org/rustup.sh -O $ sh rustup.sh ``` 此命令下载一个脚本并开始安装`rustup`工具,这会安装最新稳定版 `Rust`。过程中可能会提示你输入密码。如果安装成功,将会出现如下内容: ``` Rust is installed now. Great! ``` 此安装脚本自动将 Rust 加入系统 PATH 环境变量中,在下一次登录时生效。 手动将 Rust 加入系统 PATH 变量中,立即生效的命令 ``` $ source $HOME/.cargo/env ``` 或者,可以在*~/.bash\_profile*文件中增加如下行: ``` $ export PATH="$HOME/.cargo/bin:$PATH" $ echo 'source /etc/profile' >> ~/.bashrc ``` Rust 需要c编译器gcc的支持 ``` //linux 下执行 $ yum install gcc //Mac OS下执行 $ brew install gcc ``` #### **更新和卸载** 通过shell脚本更新Rust。 可以通过 `rustup --help` 查看rustup支持的参数 ``` rustup update ``` 为了卸载 `Rust`和`rustup`,在 shell 中运行如下卸载脚本: ``` $ rustup self uninstall ``` 查看版本 ``` $ rustup --version ``` #### 安装nightly(开发版本) ``` $ rustup install nightly ``` 查看 ``` $ rustup toolchain list ``` 可以在项目目录使用`rustup override`来设置当前目录`rustup`使用 nightly 工具链作: ``` $ cd ~/projects/needs-nightly //工作目录 $ rustup override set nightly ``` ### **编辑器安装** #### **IntelliJ Rust 插件** >使用`IntelliJ clion` + [IntelliJ Rust](https://link.zhihu.com/?target=https%3A//intellij-rust.github.io/) 下载安装好 [CLion](https://link.zhihu.com/?target=https%3A//www.jetbrains.com/clion/download) 后,在 `Settings -> Plugins -> Install JetBrains Plugins` 里查找 Rust 即可下载安装 IntelliJ Rust 插件。安装好插件后可以通过 `Settings -> Languages & Framworks -> Rust`配置标准库路径和其他选项。 ### **Dockerfile安装Rust** ``` From centos:7 WORKDIR /usr/src/ Run yum install -y net-tools \ iproute \ dos2unix \ vim \ gcc Run curl -f -L https://static.rust-lang.org/rustup.sh -O \ && sh rustup.sh \ #&& source $HOME/.cargo/env \ &&echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> /etc/profile \ && source /etc/profile \ && echo 'source /etc/profile"' >> ~/.bashrc \ && ldconfig \ && rustup update CMD /bin/bash ```