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

"Hello world" example doesn't compile... #1714

Closed
1 task done
steveklabnik opened this issue Jan 20, 2023 · 1 comment · Fixed by #1715
Closed
1 task done

"Hello world" example doesn't compile... #1714

steveklabnik opened this issue Jan 20, 2023 · 1 comment · Fixed by #1715

Comments

@steveklabnik
Copy link

  • I have looked for existing issues (including closed) about this

Bug Report

https://docs.rs/axum/latest/axum/ has a "Hello world", but if you try it, by default it doesn't work.

Version

0.6.2

Platform

Description

$ cargo build
error[E0433]: failed to resolve: use of undeclared crate or module `tokio`
 --> src\main.rs:6:3
  |
6 | #[tokio::main]
  |   ^^^^^ use of undeclared crate or module `tokio`

error[E0752]: `main` function is not allowed to be `async`
 --> src\main.rs:7:1
  |
7 | async fn main() {
  | ^^^^^^^^^^^^^^^ `main` function is not allowed to be `async`

Adding a cargo add tokio --features macros,rt-multi-thread fixes this, but I had to figure it out myself, and I'm still not 100% that that runtime feature is what I'm supposed to be using here.

Adding something about this into the documentation to help guide new users would be great.

@jplatte
Copy link
Member

jplatte commented Jan 20, 2023

rt-multi-thread is right, but I agree the docs could be more helpful here.

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

Successfully merging a pull request may close this issue.

2 participants