Cargo: error: failed to run custom build command for `openssl-sys v0.9.99` — Could not find directory of OpenSSL installation / pkg-config not found
The openssl-sys crate can't find OpenSSL headers/libraries (or pkg-config) to link against.
error: failed to run custom build command for `openssl-sys v0.9.99`Could not find directory of OpenSSL installation, and this `-sys` crate cannot proceed without this knowledgeCould not find openssl via pkg-configpkg-config has not been configured to support cross-compilationThe system library `openssl` required by crate `openssl-sys` was not found Meaning
Install the dev package: Debian/Ubuntu sudo apt install pkg-config libssl-dev, Fedora openssl-devel, Alpine openssl-dev, macOS brew install openssl@3 and set OPENSSL_DIR=$(brew --prefix openssl@3). Or avoid system OpenSSL: use rustls features (reqwest = { default-features = false, features = ["rustls-tls"] }) or the vendored feature of openssl.
Common causes
- libssl-dev/pkg-config missing
- macOS OpenSSL not found (Homebrew path)
- Cross compiling without target OpenSSL
- OpenSSL 3 vs old crate version
- Musl/Alpine builds
⚡ Quick fix
sudo apt install pkg-config libssl-dev- macOS:
export OPENSSL_DIR=$(brew --prefix openssl@3) - Use rustls or
openssl = { version = "0.10", features = ["vendored"] }
Detailed fix by platform
Linux
sudo apt install -y pkg-config libssl-dev && cargo build
How to diagnose
- Package — libssl-dev?
- Env — OPENSSL_DIR?
- Alternative — rustls/vendored?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Blocking waiting for file lock on package cache / build directory Cargo: Blocking waiting for file lock on package cache / on build directory
- ca md too weak / ee key too small OpenSSL: error:0A00018E:SSL routines::ca md too weak / error:140AB18F:SSL routines:SSL_CTX_use_certificate:ee key too small
- cargo: failed to get from registry (spurious network error) Cargo: warning: spurious network error (2 tries remaining): [35] SSL connect error / error: failed to download from `https://index.crates.io/...`
Most viewed in Rust
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026