terça-feira, 18 de fevereiro de 2025

Solution to failed to run custom build command for `openssl-sys v0.9.104`

 When upgrading "reqwests" library I got the following error on docker build:

#18 182.8 The following warnings were emitted during compilation:

#18 182.8 

#18 182.8 warning: openssl-sys@0.9.104: Could not find directory of OpenSSL installation, and this `-sys` crate cannot proceed without this knowledge. If OpenSSL is installed and this crate had trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the compilation process. See stderr section below for further information.

#18 182.8 

#18 182.8 error: failed to run custom build command for `openssl-sys v0.9.104`

#18 182.8 

#18 182.8 Caused by:

#18 182.8   process didn't exit successfully: `/usr/app/target/release/build/openssl-sys-ff7852766e78b685/build-script-main` (exit status: 101)

#18 182.8   --- stdout

#18 182.8   cargo:rustc-check-cfg=cfg(osslconf...

 

Could not find the solution after googling, but I tried the obvious solution, install openssl-dev into the docker image:

FROM rust:1.82-alpine AS builder

RUN apk add --no-cache openssl-dev


After this I got the following error:

x86_64-alpine-linux-musl/bin/ld: cannot find -lssl: No such file or directory

x86_64-alpine-linux-musl/bin/ld: cannot find -lcrypto: No such file or directory


And the fix for this was adding the openssl-libs-static:

FROM rust:1.82-alpine AS builder

RUN apk add --no-cache openssl-dev openssl-libs-static

 

Fixed


Nenhum comentário:

Postar um comentário