#"Unresolved import 'actix_web::HttpServer' / no 'HttpServer' in root" even in example server

1 messages · Page 1 of 1 (latest)

lament fern
#

What does your Cargo.toml look like

lament fern
#
[package]
name = "actix-example-test"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
actix-files = "0.6.2"
actix-web = "4"
serde_json = "1.0.94"
use actix_web::{web, App, HttpResponse, HttpServer};

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| App::new().route("/", web::get().to(HttpResponse::Ok)))
        .bind(("127.0.0.1", 8080))?
        .run()
        .await
}

this works fine for me on linux

#

i wonder if trying cargo clean will help you

lament fern
#

what version of rust are you using

#

and what version of linux

#

sorry, i meant what distro, not which kernel version

lament fern
#

idk what to tell you

$ uname -a
Linux graystripe 6.1.15 #1-NixOS SMP PREEMPT_DYNAMIC Fri Mar  3 10:52:25 UTC 2023 x86_64 GNU/Linux

$ cargo --version
cargo 1.68.0 (115f34552 2023-02-26)

$ rustc --version                                 
rustc 1.68.0 (2c8cc3432 2023-03-06)

Using the exact code I sent earlier, the cargo build succeeds

#

would you happen to be on ARM or RISCV or another non-x86 architecture?

lament fern
#

interesting. I wonder why the cache was messed up 🤔