Gab*_*rez 6 rust rustup rust-rocket
我正在尝试使用 Rocket 构建一个 Rust 项目,但在编译时我总是遇到此错误,即使在成功覆盖项目的工具链之后也是如此:
D:\GitHub\Learning-Rust\poke_api> rustup override set nightly
info: using existing install for 'nightly-x86_64-pc-windows-msvc'
info: override toolchain for 'D:\GitHub\Learning-Rust\poke_api' set to 'nightly-x86_64-pc-windows-msvc'
nightly-x86_64-pc-windows-msvc unchanged - rustc 1.52.0-nightly (4a8b6f708 2021-03-11)
PS D:\GitHub\Learning-Rust\poke_api> cargo build
Compiling winapi v0.3.9
Compiling serde_derive v1.0.124
Compiling rocket v0.4.7
Compiling pear_codegen v0.1.4
Compiling rocket_codegen v0.4.7
Compiling proc-macro2 v1.0.24
Compiling pq-sys v0.4.6
Compiling aho-corasick v0.6.10
Compiling serde_json v1.0.64
error: failed to run custom build command for `pear_codegen v0.1.4`
Caused by:
process didn't exit successfully: `D:\GitHub\Learning-Rust\poke_api\target\debug\build\pear_codegen-e182711746033ac9\build-script-build` (exit code: 101)
--- stderr
Error: Pear requires a 'dev' or 'nightly' version of rustc.
Installed version: 1.48.0 (2020-11-16)
Minimum required: 1.31.0-nightly (2018-10-05)
thread 'main' panicked at 'Aborting compilation due to incompatible compiler.', C:\Users\gabre\.cargo\registry\src\github.com-1ecc6299db9ec823\pear_codegen-0.1.4\build.rs:24:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
Run Code Online (Sandbox Code Playgroud)
Oso*_*oro 16
我在使用火箭时遇到了类似的问题。同样的错误信息,Error: Pear requires a 'dev' or 'nightly' version of rustc.
如果您进入Rocket Framework 网站上的入门页面。它说,“Rocket 充分利用了 Rust 的语法扩展和其他高级、不稳定的功能。因此,我们需要使用 Rust 的夜间版本。”
我的问题是我没有使用夜间版本的 Rust。在我的项目目录中的终端上运行它对我来说是这样。
rustup override set nightly
Run Code Online (Sandbox Code Playgroud)
如果您之后检查该目录的货物版本,
cargo version
Run Code Online (Sandbox Code Playgroud)
您将确认它已切换到夜间版本