Rocket_contrib not found

Hi,

I am currently doing a course on APIs in Rust and I followed the course so far but I ran into a problem with rocket_contrib.
This is my exact error message while running cargo run

Updating git repository `https://github.com/SergioBenitez/Rocket`
Updating crates.io index
error: no matching package named `rocket_contrib` found
location searched: https://github.com/SergioBenitez/Rocket

these are the dependencies in my Cargo.toml

[dependencies]
rocket = { git = "https://github.com/SergioBenitez/Rocket" }
serde_json = "1.0"
[dependencies.rocket_contrib]
git = "https://github.com/SergioBenitez/Rocket"
default-features = false
features = ["json"]

How can I fix that problem?

Looks like rocket_contrib was split into separate crates just 5 hours ago. In general depending on the main branch of a repository like this is liable to suddenly cause breakage when changes are made to it. Your options are basically:

  • just use the latest versions from crates.io
[dependencies]
rocket = "0.4"
serde_json = "1.0"
rocket_contrib = { version = "0.4", default-features = false, features = ["json"] }
  • specify a tag instead of using the latest git commit
[dependencies.rocket_contrib]
git = "https://github.com/SergioBenitez/Rocket"
tag = "some-tag-from-the-git-repo"
default-features = false
features = ["json"]
  • figure out what changed and update your code to use the new crates instead of rocket_contrib

I would recommend the first choice. Additionally, if these dependencies were specified by the course organizer(s) you may want to let them know they have a bug in their course material.

Oh... That's definitely the problem. According to the course I have to stick to the development version as long as 0.5 isn't available.

I see, in that case you could try to depend on both of the new crates rocket_sync_db_pools and rocket_dyn_templates and try to figure out where everything was moved. For example, rocket_contrib::templates::Template is now rocket_dyn_templates::Template and so on. They didn't actually change the contents of the contrib crate as far as I can tell, just moved things around, so hopefully you would be able to get by with just changing some import statements.

thanks for your help. It doesn't seem like I get it running right now because I really lack the skills in rust for now. I reported the problem to the instructor and hope that he will fix the problem.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.