rust - `错误:无法为`openssl-sys v0.9.67`运行自定义构建命令
问题描述
我正在构建我的货物码头文件。以前可以用,现在不行了。
我收到此错误:
error: failed to run custom build command for `openssl-sys v0.9.67
根据我的多次挖掘,我做了很多事情:
brew install openssl
brew install pkg-config
brew install perl
我也在 cargo.toml 的依赖项中添加了以下内容
openssl-sys = "0.9"
openssl = { version = "0.10.33", features = ["vendored"] }
我什至在我的 .profile 中添加了以下内容
export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"
还是行不通。该错误仅在 docker build 运行期间显示。
---这是错误---
#7 133.6 error: failed to run custom build command for `openssl-sys v0.9.67`
#7 133.6
#7 133.6 Caused by:
#7 133.6 process didn't exit successfully: `/build-xxx/target/release/build/openssl-sys-bb0d0329fb009fff/build-script-main` (exit status: 101)
#7 133.6 --- stdout
#7 133.6 cargo:rustc-cfg=const_fn
#7 133.6 cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_NO_VENDOR
#7 133.6 X86_64_UNKNOWN_LINUX_GNU_OPENSSL_NO_VENDOR unset
#7 133.6 cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
#7 133.6 OPENSSL_NO_VENDOR unset
#7 133.6 CC_x86_64-unknown-linux-gnu = None
#7 133.6 CC_x86_64_unknown_linux_gnu = None
#7 133.6 HOST_CC = None
#7 133.6 CC = None
#7 133.6 CFLAGS_x86_64-unknown-linux-gnu = None
#7 133.6 CFLAGS_x86_64_unknown_linux_gnu = None
#7 133.6 HOST_CFLAGS = None
#7 133.6 CFLAGS = None
#7 133.6 CRATE_CC_NO_DEFAULTS = None
#7 133.6 DEBUG = Some("false")
#7 133.6 CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
#7 133.6 running "perl" "./Configure" "--prefix=/build-xxx/target/release/build/openssl-sys-c2883a05afa95d60/out/openssl-build/install" "no-dso" "no-shared" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" "no-zlib-dynamic" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "linux-x86_64" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64"
#7 133.6
#7 133.6 --- stderr
#7 133.6 Can't locate FindBin.pm in @INC (you may need to install the FindBin module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl) at ./Configure line 15.
#7 133.6 BEGIN failed--compilation aborted at ./Configure line 15.
#7 133.6 thread 'main' panicked at '
#7 133.6
#7 133.6
#7 133.6 Error configuring OpenSSL build:
#7 133.6 Command: "perl" "./Configure" "--prefix=/build-xxx/target/release/build/openssl-sys-c2883a05afa95d60/out/openssl-build/install" "no-dso" "no-shared" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" "no-zlib-dynamic" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "linux-x86_64" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64"
#7 133.6 Exit status: exit status: 2
#7 133.6
#7 133.6
#7 133.6 ', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/openssl-src-111.16.0+1.1.1l/src/lib.rs:479:13
#7 133.6 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
#7 133.6 warning: build failed, waiting for other jobs to finish...
#7 133.7 error: build failed
#7 ERROR: executor failed running [/bin/sh -c cd /build-xxx/ && rustup default nightly && rustup update && cargo build --release]: exit code: 101
---下面是我的docker文件---
FROM rust:slim
COPY . /build-xxx/
RUN cd /build-xxx/ && rustup default nightly && rustup update && cargo build --release
LABEL Name=XXX Version=0.0.1
EXPOSE 8000
ENV ROCKET_ENV=stage
CMD ["/build-xxx/target/release/xxx"]
解决方案
由于我的错误只发生在 docker build 中,我更新了 dockerfile 并添加了 OpenSSL 所需的依赖项(build-essential checkinstall zlib1g-dev)。
我将我的 docker 文件更改为下面的文件,它可以工作!
FROM rust:slim
RUN apt-get update && apt-get install -y \
build-essential checkinstall zlib1g-dev -y
COPY . /build-xxx/
RUN cd /build-xxx/ && rustup default nightly && rustup update && cargo build --release
LABEL Name=XXX Version=0.0.1
EXPOSE 8000
ENV ROCKET_ENV=stage
CMD ["/build-xxx/target/release/xxx"]
推荐阅读
- php - Lumen Jwt 身份验证获取(参数 2 传递给 Tymon\JWTAuth\JWTGuard)错误
- python - Pandas - 检查重复项
- swift - @State 私有变量是不可变的
- javascript - Intl.NumberFormat 格式美分转换为正确格式
- groovy - 将 LocalDateTime 转换为 unix 时间格式 - groovy.lang.MissingMethodException
- c++ - C ++中静态分配与动态分配的数组
- apache-kafka - 使用 MassTransit 的不可预测的 Kafka 偏移行为
- python - 如何使用networkx读取json图?
- visual-studio - 如何在 VS 中抑制此警告:“不支持应用于文档的架构类型”
- android - Android 传感器规格:单位、满量程