作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在关注 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 update
和 cargo 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/
我是一名优秀的程序员,十分优秀!