actix_rt2.0.2的“系统未运行”

我尝试更新到 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
}

货物.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"

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

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

提前感谢您的任何见解。

干杯!

回答

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

actix = "0.11.0-beta.2"
actix-web = "4.0.0-beta.3"
actix-rt = "2.0.2"

  • thanks it worked for me. It is my first Rust program, and this is my first error and to be honest I find it quite disappointing that there is not a meaningful error message that hints me in the direction.. "System is not running" yeah, thanks Cptn Obvious! It would be great if the compiler would check some repo for incompatible versions and report exactly that error! I will continue with Rust, but if stuff like this happens more often, I will quit it. Good error reporting is a must when learning a new language.
  • @Max But how do I know which version is compatible with each other?
  • @Eren I looked here https://crates.io/crates/actix-rt/2.1.0/dependencies to check. I agree this is confusing and avoidable, as pointed out to the maintainers here https://github.com/actix/actix-net/issues/281#issuecomment-792275955

以上是actix_rt2.0.2的“系统未运行”的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>