Skip to content

Fix macOS CI build by ensuring environment variables are available to cargo build#2

Merged
keaz merged 3 commits into
mainfrom
copilot/fix-ci-build-issue-macos
Oct 10, 2025
Merged

Fix macOS CI build by ensuring environment variables are available to cargo build#2
keaz merged 3 commits into
mainfrom
copilot/fix-ci-build-issue-macos

Conversation

Copilot AI commented Oct 10, 2025

Copy link
Copy Markdown
Contributor

Problem

The GitHub Actions CI workflow was failing when building for macOS. The rdkafka crate's native dependencies (rdkafka-sys and openssl-sys) require specific environment variables to locate OpenSSL and librdkafka during compilation, but these weren't being properly propagated to the cargo build process.

Root Cause

While the "Install dependencies on macOS" step correctly installed dependencies via Homebrew and added environment variables (OPENSSL_DIR, PKG_CONFIG_PATH, LDFLAGS, CPPFLAGS) to $GITHUB_ENV, these variables needed to be explicitly declared in the cargo build step to ensure they're available to all subprocesses, including the build scripts that compile native dependencies.

Solution

Added an explicit env: block to the "Build with Cargo" step that declares the required environment variables:

- name: Build with Cargo
  env:
    OPENSSL_DIR: ${{ env.OPENSSL_DIR }}
    PKG_CONFIG_PATH: ${{ env.PKG_CONFIG_PATH }}
    LDFLAGS: ${{ env.LDFLAGS }}
    CPPFLAGS: ${{ env.CPPFLAGS }}
  run: |
    # ... build commands

This ensures:

  • OPENSSL_DIR points to the OpenSSL@3 installation (required by openssl-sys)
  • PKG_CONFIG_PATH tells pkg-config where to find .pc files for OpenSSL, librdkafka, zstd, and lz4
  • LDFLAGS tells the linker where to find the shared libraries
  • CPPFLAGS tells the C compiler where to find header files

Additional Changes

  • Added debug output to print environment variable values during the build for easier troubleshooting
  • Created CI_MACOS_FIX.md documentation explaining the fix

Testing

The fix should be validated by the CI workflow running successfully on macOS runners. The debug output will confirm that environment variables are properly set before the cargo build executes.

Original prompt

Currently ci.yml GitHub worklfow is failing when bilding for macOS. Fix that build issue.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits October 10, 2025 06:30
…build step

Co-authored-by: keaz <8468375+keaz@users.noreply.github.com>
Co-authored-by: keaz <8468375+keaz@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix build issue for macOS in ci.yml Fix macOS CI build by ensuring environment variables are available to cargo build Oct 10, 2025
Copilot AI requested a review from keaz October 10, 2025 06:33
@keaz
keaz marked this pull request as ready for review October 10, 2025 07:35
@keaz
keaz merged commit 8ad7a6c into main Oct 10, 2025
@keaz
keaz deleted the copilot/fix-ci-build-issue-macos branch October 10, 2025 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants