actix_rt 2.0.2 的“系统未运行”

Mar*_*ick 9 compiler-errors rust-actix actix-web

我尝试更新到 actix_rt 2.0.2,但一直收到以下错误:

线程“main”因“系统未运行”而恐慌

我的最小例子在这里

use actix_rt;
use actix_web::{HttpServer, App, HttpResponse};

async fn hello() -> HttpResponse {
    HttpResponse::Ok().finish()
}

#[actix_rt::main]
async fn main() -> std::io::Result<()> {
    let server = HttpServer::new(move || {
        App::new().route("/", actix_web::web::get().to(hello))
    });
    server.bind("127.0.0.1:8080")?.run().await
}
Run Code Online (Sandbox Code Playgroud)

货物.toml

[package]
name = "my_app"
version = "2.2.0"
authors = ["me"]
edition = "2018"

[dependencies]
actix = "0.10"
actix-web = { version = "3.3.2", default-features = false }
actix-rt = "2.0.2"
Run Code Online (Sandbox Code Playgroud)

我假设它一定是actix板条箱之间的某些版本不兼容。是否有版本号的组合或我缺少的一些明显的东西来让它们一起工作?

我需要 actix_rt 2.0.x 以便我可以与Criterion集成

提前感谢您的任何见解。

干杯!

Max*_*Max 10

您的 actix crate 版本不兼容。您可以降级actix-rt1,或升级到测试版,例如:

actix = "0.11.0-beta.2"
actix-web = "4.0.0-beta.3"
actix-rt = "2.0.2"
Run Code Online (Sandbox Code Playgroud)

  • 谢谢它对我有用。这是我的第一个 Rust 程序,也是我的第一个错误,说实话,我发现它非常令人失望,因为没有任何有意义的错误消息提示我方向。“系统没有运行”是的,谢谢 Cptn 显而易见!如果编译器能够检查某些存储库中是否存在不兼容的版本并准确报告该错误,那就太好了!我会继续使用 Rust,但如果这样的事情发生得更频繁,我会放弃它。学习一门新语言时,良好的错误报告是必须的。 (5认同)
  • @Max但是我怎么知道哪个版本彼此兼容? (2认同)
  • @Eren 我在这里查看 https://crates.io/crates/actix-rt/2.1.0/dependencies 进行检查。我同意这是令人困惑且可以避免的,正如此处向维护者指出的那样 https://github.com/actix/actix-net/issues/281#issuecomment-792275955 (2认同)