Yohannes Kifle
Yohannes Kifle

Reputation: 41

How to use rocket on stable release of Rust

I am trying to use stable version of rustc to compile a rocket web application. rocket crate compiles fine but I would like to use a static file server from rocket_contrib. My Cargo.toml file looks like this:

[dependencies]
rocket = "0.5.0-rc.1"

[dependencies.rocket_dyn_templates]
version = "0.1.0-rc.1"
features = ["handlebars"]

[dependencies.rocket_contrib]
version = "0.4.10"
default-features = false
features = ["serve"]

I get the following error when I try to run cargo build :

Error: Pear requires a 'dev' or 'nightly' version of rustc.
Installed version: 1.52.1 (2021-05-09)
Minimum required:  1.31.0-nightly (2018-10-05)

Upvotes: 3

Views: 1676

Answers (1)

E_net4
E_net4

Reputation: 30052

Starting from version 0.5 of Rocket, you are not expected to use rocket_contrib, because this one was split into features which are either already in the core crate or moved to separate crates. The notes from this revision (see also issue 1659) provide a few more details:

This follows the completed graduation of stable contrib features into core, removing 'rocket_contrib' in its entirety in favor of two new crates. These crates are versioned independently of Rocket's core libraries, allowing upgrades to dependencies without consideration for versions in core libraries.

'rocket_dyn_templates' replaces the contrib 'templates' features. While largely a 1-to-1 copy, it makes the following changes:

  • the 'tera_templates' feature is now 'tera'
  • the 'handlebars_templates' feature is now 'handlebars'
  • fails to compile if neither 'tera' nor 'handlebars' is enabled

'rocket_sync_db_pools' replaces the contrib 'database' features. It makes no changes to the replaced features except that the database attribute is properly documented at the crate root.

In short, you will need to migrate your code away from rocket_contrib. Better guidelines may become available once v0.5 is definitely released, but until then, you may look for the features once available in rocket_contrib in the core documentation and respective Cargo feature list.

Upvotes: 7

Related Questions