Skip to content

Cargo source build rejects OpenSSL 4

Source: Troubleshooting reference

Symptom: rust-docs-mcp or another Cargo source fallback fails in openssl-sys with version: 4_0_3 and a message that only OpenSSL 1.x or 3 is supported. OPENSSL_DIR unset is diagnostic output, not the failure itself.

Cause: Homebrew’s global pkg-config search finds OpenSSL 4, while the crate’s locked openssl-sys version rejects that major. An installed OpenSSL 3 keg is insufficient unless the build selects its versioned path. A later successful doctor check can belong to the previously installed binary; the failed replacement still makes install/rust.sh fail.

Confirm: compare default discovery with the available OpenSSL 3 headers:

Terminal window
pkg-config --modversion openssl
brew --prefix openssl@3
test -f "$(brew --prefix openssl@3)/include/openssl/ssl.h"

Fix: update the checkout and retry the Rust installer. If OpenSSL 3 is absent, install its declared Brewfile dependency first:

Terminal window
brew install openssl@3
bash ~/dotfiles/install/rust.sh

The installer selects opt/openssl@3 for source builds through OPENSSL_DIR, adds its library directory to Linux runtime search paths, preserves explicit OpenSSL path overrides, and leaves global Homebrew links unchanged. Expect the source-build log to name OpenSSL 3 and the final count to report zero failures. If you explicitly selected OpenSSL 4, remove or correct that override before retrying. See Cargo package behavior and the upstream build variables.