fix(build): vendor OpenSSL on macOS so the build works natively #82

Merged
David merged 2 commits from fix/macos-build into main 2026-07-28 11:28:10 +02:00
Owner

cargo build failed on a stock Mac: openssl-sys cannot find a system OpenSSL because macOS ships neither OpenSSL headers nor pkg-config, and git2's https + ssh features pull it in through libgit2-sys and libssh2-sys. The crate already vendors OpenSSL for musl and Windows for the same reason, so extend that to cfg(target_os = "macos").

The macOS entry has to appear twice. ssh2-config declares an unconditional git2 build-dependency, which puts a second openssl-sys in the build-script half of the graph, and Cargo's v2 resolver resolves build-dependency features separately from normal-dependency ones. With only the normal-dependency entry the build-script copy still went looking for a system OpenSSL and failed, so a matching [target.'cfg(target_os = "macos")'.build-dependencies.openssl] puts openssl-sys/vendored on the build side too.

Nothing changes for the release targets: both entries are gated on cfg(target_os = "macos"), and Cargo.lock is untouched because the vendored openssl was already locked for the musl and Windows targets. The nix flake gains perl on Darwin, which openssl-src shells out to during the vendored build. Verified on aarch64-apple-darwin: debug and release builds, the full test suite (9 binaries, no failures), cargo fmt --check, cargo clippy, a live fj repo view against codeberg.org, and a live fj repo clone over https, which exercises libgit2 against the vendored OpenSSL at runtime.

Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com

`cargo build` failed on a stock Mac: `openssl-sys` cannot find a system OpenSSL because macOS ships neither OpenSSL headers nor `pkg-config`, and `git2`'s `https` + `ssh` features pull it in through `libgit2-sys` and `libssh2-sys`. The crate already vendors OpenSSL for musl and Windows for the same reason, so extend that to `cfg(target_os = "macos")`. The macOS entry has to appear twice. `ssh2-config` declares an unconditional `git2` build-dependency, which puts a second `openssl-sys` in the build-script half of the graph, and Cargo's v2 resolver resolves build-dependency features separately from normal-dependency ones. With only the normal-dependency entry the build-script copy still went looking for a system OpenSSL and failed, so a matching `[target.'cfg(target_os = "macos")'.build-dependencies.openssl]` puts `openssl-sys/vendored` on the build side too. Nothing changes for the release targets: both entries are gated on `cfg(target_os = "macos")`, and Cargo.lock is untouched because the vendored `openssl` was already locked for the musl and Windows targets. The nix flake gains `perl` on Darwin, which `openssl-src` shells out to during the vendored build. Verified on aarch64-apple-darwin: debug and release builds, the full test suite (9 binaries, no failures), `cargo fmt --check`, `cargo clippy`, a live `fj repo view` against codeberg.org, and a live `fj repo clone` over https, which exercises libgit2 against the vendored OpenSSL at runtime. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
fix(build): vendor OpenSSL on macOS so the build works natively
Some checks failed
Check / fmt + clippy + build + tests (pull_request) Failing after 8s
deba47592b
`cargo build` failed on a stock Mac: `openssl-sys` cannot find a system OpenSSL because macOS ships neither OpenSSL headers nor `pkg-config`, and `git2`'s `https` + `ssh` features pull it in through `libgit2-sys` and `libssh2-sys`. The crate already vendors OpenSSL for musl and Windows for the same reason, so extend that to `cfg(target_os = "macos")`.

The macOS entry has to appear twice. `ssh2-config` declares an unconditional `git2` build-dependency, which puts a second `openssl-sys` in the build-script half of the graph, and Cargo's v2 resolver resolves build-dependency features separately from normal-dependency ones. With only the normal-dependency entry the build-script copy still went looking for a system OpenSSL and failed, so a matching `[target.'cfg(target_os = "macos")'.build-dependencies.openssl]` puts `openssl-sys/vendored` on the build side too.

Nothing changes for the release targets: both entries are gated on `cfg(target_os = "macos")`, and Cargo.lock is untouched because the vendored `openssl` was already locked for the musl and Windows targets. The nix flake gains `perl` on Darwin, which `openssl-src` shells out to during the vendored build. Verified on aarch64-apple-darwin: debug and release builds, the full test suite (9 binaries, no failures), `cargo fmt --check`, `cargo clippy`, a live `fj repo view` against codeberg.org, and a live `fj repo clone` over https, which exercises libgit2 against the vendored OpenSSL at runtime.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
David scheduled this pull request to auto merge when all checks succeed 2026-07-28 10:52:51 +02:00
Merge branch 'main' into fix/macos-build
All checks were successful
Check / fmt + clippy + build + tests (pull_request) Successful in 35s
Create release / Create release from merged PR (pull_request) Has been skipped
d951a38156
David merged commit f7bcce81a0 into main 2026-07-28 11:28:10 +02:00
David deleted branch fix/macos-build 2026-07-28 11:28:10 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pandoras-box/forgejo-cli!82
No description provided.