Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rocket example doesn't compile: can't find crate for rocket_codegen #33

Closed
Boscop opened this issue Jul 23, 2018 · 9 comments
Closed

Rocket example doesn't compile: can't find crate for rocket_codegen #33

Boscop opened this issue Jul 23, 2018 · 9 comments

Comments

@Boscop
Copy link

Boscop commented Jul 23, 2018

D:\3rdparty\rust-embed [master ≡]> cargo run --example rocket
←[0m←[0m←[1m←[32m    Updating←[0m registry `https://github.com/rust-lang/crates.io-index`
←[0m←[0m←[1m←[32m   Compiling←[0m winapi v0.3.5
←[0m←[0m←[1m←[32m   Compiling←[0m unicode-xid v0.0.4
←[0m←[0m←[1m←[32m   Compiling←[0m quote v0.3.15
←[0m←[0m←[1m←[32m   Compiling←[0m synom v0.11.3
←[0m←[0m←[1m←[32m   Compiling←[0m syn v0.11.11
←[0m←[0m←[1m←[32m   Compiling←[0m same-file v1.0.2
←[0m←[0m←[1m←[32m   Compiling←[0m walkdir v2.1.4
←[0m←[0m←[1m←[32m   Compiling←[0m rust-embed v3.0.0 (file:///D:/3rdparty/rust-embed)
←[0m←[1m←[38;5;9merror[E0463]←[0m←[0m←[1m←[38;5;15m: can't find crate for `rocket_codegen`←[0m
←[0m ←[0m←[0m←[1m←[38;5;14m--> ←[0m←[0mexamples\rocket.rs:2:11←[0m
←[0m  ←[0m←[0m←[1m←[38;5;14m|←[0m
←[0m←[1m←[38;5;14m2←[0m←[0m ←[0m←[0m←[1m←[38;5;14m| ←[0m←[0m#![plugin(rocket_codegen)]←[0m
←[0m  ←[0m←[0m←[1m←[38;5;14m| ←[0m←[0m          ←[0m←[0m←[1m←[38;5;9m^^^^^^^^^^^^^^←[0m←[0m ←[0m←[0m←[1m←[38;5;9mcan't f
ind crate←[0m

←[0m←[1m←[38;5;9merror←[0m←[0m←[1m←[38;5;15m: aborting due to previous error←[0m

←[0m←[1m←[38;5;15mFor more information about this error, try `rustc --explain E0463`.←[0m
←[0m←[0m←[1m←[31merror:←[0m Could not compile `rust-embed`.

To learn more, run the command again with --verbose.
@pyrossh
Copy link
Owner

pyrossh commented Jul 23, 2018

What version of rust are you using? The rocket example only works on the nightly version.
You need to run this specifically
cargo +nightly run --example rocket --features nightly

@Boscop
Copy link
Author

Boscop commented Jul 23, 2018

Ah, I had nightly but I didn't have --features nightly..
Now it works (but crashes when run from examples folder (issue 34)).

@Boscop Boscop closed this as completed Jul 23, 2018
@theronic
Copy link

theronic commented Feb 7, 2019

I can't get rust_codegen plugin working either, even on nightly rust. I get "Package myproject does not have these features: nightly"

@rsdomingues
Copy link

i've got the same error here.

cargo +nightly run --example rocket --features nightly

error: Package hero-api v0.1.0 (/Users/rodrigosd/git/rust/hero-api) does not have these features: nightly

if i try only cargo run

error: dlsym(0x7fa7b74156b0, rustc_plugin_registrar_e7907f37b0dc50ddf9d71b111db3523f): symbol not found
--> src/main.rs:5:11
|
5 | #![plugin(rocket_codegen)]
| ^^^^^^^^^^^^^^

error: aborting due to previous error

@AzureMarker
Copy link
Collaborator

@rsdomingues Are you executing that in this library or your own? What is hero-api?

@Oni-zerone
Copy link

@Mcat12 I had the same problem, and I think @rsdomingues is refering to this tutorial https://medium.com/sean3z/building-a-restful-crud-api-with-rust-1867308352d8
that is the first result on google searching for rust rest api.
Do you have a better documentation to share with us?

@AzureMarker
Copy link
Collaborator

AzureMarker commented May 29, 2019

What is the goal that you/they are trying to accomplish? It doesn't make sense to try to run another crate's examples from your own project. You need to be in the rust-embed crate to run rust-embed examples.

@web3dopamine
Copy link

web3dopamine commented May 7, 2020

@Oni-zerone

  1. in Cargo.toml
    [dependencies]
    rocket = "0.4.4"
    rocket_codegen = "0.4.4"

  2. main.rs

#![feature(proc_macro_hygiene, decl_macro)]

#[macro_use] extern crate rocket;

#[get("/<name>/<age>")]
fn hello(name: String, age: u8) -> String {
    format!("Hello, {} year old named {}!", age, name)
}

fn main() {
    rocket::ignite()
        .mount("/hello", routes![hello])
        .launch();
}

check the first two lines; its different for rocket v0.3 and v0.4

it should work now... :)

@AkhilSharma90
Copy link

@web3dopamine your solution works thanks. I wish they stuck with the old syntax (pre v0.3) for the first two lines. that made more sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants