failed to run custom build command for openssl-sys Rust Origin: Application & API OSI layer 7 · Application Last updated 5 Nov 2026

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.

Exact message you may see 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
Seen on: Rust SSL Linux

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

  1. sudo apt install pkg-config libssl-dev
  2. macOS: export OPENSSL_DIR=$(brew --prefix openssl@3)
  3. Use rustls or openssl = { version = "0.10", features = ["vendored"] }

Detailed fix by platform

Linux

  1. sudo apt install -y pkg-config libssl-dev && cargo build

How to diagnose

  1. Package — libssl-dev?
  2. Env — OPENSSL_DIR?
  3. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

Blocking waiting for file lock on package cache / build directory — Cargo: Blocking waiting for file lock on package cache / on build directory (Rust)Blocking waiting for …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 (SSL / TLS)ca md too weak / ee k…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/...` (Rust)cargo: failed to get …cargo: failed to select a version for the requirement — Cargo: error: failed to select a version for the requirement `serde = "^2.0"` — candidate versions found which didn't match: 1.0.197 (Rust)cargo: failed to sele…error: linker `cc` not found — Rust: error: linker `cc` not found — note: No such file or directory (os error 2) (Rust)error: linker `cc` no…feature edition2024 is required / Cargo.lock version too new — Cargo: error: failed to parse manifest — feature `edition2024` is required / lock file version 4 requires `-Znext-lockfile-bump` (Rust)feature edition2024 i…ld: library not found for -lssl — macOS: ld: library 'ssl' not found / ld: library not found for -lssl (clang: error: linker command failed) (macOS)ld: library not found…no start line — OpenSSL: unable to load certificate / PEM routines:get_name:no start line (key values mismatch) (SSL / TLS)no start linefailed to…

Explore the map of this error Full error map →

🧠 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.