The GitHub Actions CI workflow (ci.yml) was failing when building for macOS. The issue was that environment variables needed for building the rdkafka Rust crate with its native dependencies were not being properly propagated to the cargo build step.
While the "Install dependencies on macOS" step correctly set environment variables like OPENSSL_DIR, PKG_CONFIG_PATH, LDFLAGS, and CPPFLAGS and added them to $GITHUB_ENV, these variables needed to be explicitly available during the cargo build process. The rdkafka-sys crate's build script requires these variables to locate OpenSSL and librdkafka during compilation.
Added an explicit env: block to the "Build with Cargo" step that references the environment variables set in previous steps:
- 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 commandsThis ensures that:
OPENSSL_DIR- Points to the OpenSSL installation (required by openssl-sys crate)PKG_CONFIG_PATH- Tells pkg-config where to find .pc files for OpenSSL, librdkafka, zstd, and lz4LDFLAGS- Tells the linker where to find the shared librariesCPPFLAGS- Tells the C compiler where to find header files
Added debug output to print the environment variable values during the build, which will help with troubleshooting if similar issues arise in the future.
The fix should be validated by running the CI workflow on a push to the main branch or by creating a tag. The workflow will:
- Install dependencies via Homebrew
- Set environment variables
- Verify dependencies are installed correctly
- Build the project with the environment variables properly set
- Create release artifacts
- CLAUDE.md - Documents the required environment variables for macOS builds
.github/workflows/ci.yml- The updated CI workflow file