gpt4 book ai didi

docker - 无法在 Docker 镜像 : "not yet stable as a const fn" 中运行 Rust 应用程序

转载 作者:行者123 更新时间:2023-11-29 08:34:51 37 4
gpt4 key购买 nike

我正在关注 the tutorial to run a Rust application in a Docker image .我的 Dockerfile 中有以下内容:

FROM rust:1.23.0

WORKDIR src/main

COPY . .

RUN cargo install

CMD ["main"]

当我使用 docker build -t my-rust-app . 运行它时,出现以下错误:

error: `std::sync::atomic::AtomicBool::new` is not yet stable as a const fn
--> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/yansi-0.4.0/src/paint.rs:274:30
|
274 | static ENABLED: AtomicBool = AtomicBool::new(true);
| ^^^^^^^^^^^^^^^^^^^^^
|
= help: in Nightly builds, add `#![feature(const_atomic_bool_new)]` to the crate attributes to enable

error: aborting due to previous error

error: Could not compile `yansi`.

如何解决此错误并在 Docker 容器中运行 Rust 应用程序?我已经研究了几个小时,并在我的 Dockerfile 中尝试了 rustup updatecargo update 的变体,但这些安装都没有解决错误。

最佳答案

AtomicBool::new 作为 const 调用是 stabilized in Rust 1.24.0 .使用该版本(或任何更新版本)进行编译可以解决您的问题:

FROM rust:1.24.0

关于docker - 无法在 Docker 镜像 : "not yet stable as a const fn" 中运行 Rust 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51372229/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com