rustrust-rocketrustup

Build fails with Error: Pear requires a 'dev' or 'nightly' version of rustc even after a successful rustup override set nightly


I'm trying to build a rust project with rocket but I always get this error when compiling, even after successfully overwriting the project's toolchain:

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

Solution

  • I had a similar issue while using rocket. Same error message too, Error: Pear requires a 'dev' or 'nightly' version of rustc.

    If you get to the get-started page on rocket framework website. It says, "Rocket makes abundant use of Rust's syntax extensions and other advanced, unstable features. Because of this, we'll need to use a nightly version of Rust."

    My issue was I was not using a nightly version of rust. Running this on my terminal in my project directory did it for me.

    rustup override set nightly
    

    If you check the cargo version for that directory after,

    cargo version
    

    you will confirm it has switched to nightly version