fix: resolve getrandom v0.2.16 compilation issues in CI/CD#204
fix: resolve getrandom v0.2.16 compilation issues in CI/CD#204AnthonyRonning merged 2 commits intomasterfrom
Conversation
- Update Rust to 1.85.0 in flake.nix to support edition2024 feature - Add CARGO_CFG_TARGET_OS workaround for getrandom compilation: - Set to 'darwin' for iOS builds on macOS runners - Set to 'linux' for Linux builds - Fixes build failures related to getrandom crate platform detection This addresses the issue where getrandom v0.2.16 fails to correctly detect the target platform, causing multiple module definition errors. See: rust-random/getrandom#641 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Deploying maple with
|
| Latest commit: |
ac164a6
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://09d68eca.maple-ca8.pages.dev |
| Branch Preview URL: | https://fix-getrandom-build-issue.maple-ca8.pages.dev |
There was a problem hiding this comment.
Greptile Summary
This PR addresses a critical build failure affecting the project's CI/CD pipelines by resolving compilation issues with the getrandom v0.2.16 crate. The changes include two key components:
Rust Version Update: The Rust toolchain is upgraded from 1.78.0 to 1.85.0 in flake.nix, a significant jump of 7 minor versions that adds support for the edition2024 feature and improves compatibility with problematic dependencies.
Platform Detection Workarounds: The PR systematically adds CARGO_CFG_TARGET_OS environment variables across all CI workflow files that install the Tauri CLI:
desktop-build.yml: Sets to 'linux' for Ubuntu runnersmobile-build.yml: Sets to 'darwin' for iOS builds on macOS runnerstestflight-on-comment.yml: Sets to 'darwin' for macOS-based TestFlight deploymentsclaude.yml: Sets to 'linux' for Linux-based builds
The changes target a known upstream issue where getrandom v0.2.16 fails to correctly detect the target platform during cross-compilation scenarios, leading to "multiple module definition errors" that break builds. By explicitly providing platform hints through the CARGO_CFG_TARGET_OS environment variable during cargo installation steps, the workaround helps the getrandom crate understand the target environment.
This fix integrates seamlessly with the existing CI/CD infrastructure without requiring dependency downgrades or major architectural changes. The approach is surgical, only affecting the specific build steps where Tauri CLI installation occurs, and maintains consistency across different target platforms (Darwin for macOS/iOS, Linux for Ubuntu runners).
Confidence score: 5/5
- This PR is safe to merge with minimal risk as it addresses a well-documented upstream issue with a proven workaround
- Score reflects targeted fixes for a specific known issue with clear upstream documentation and consistent implementation across workflows
- No files require special attention as the changes are surgical and address a specific compilation problem
5 files reviewed, no comments
WalkthroughAdds CARGO_CFG_TARGET_OS environment variables to the "Install Tauri CLI" steps across multiple GitHub Actions workflows (setting linux for Linux runners and macos for macOS runners). Also bumps the flake.nix Rust toolchain from stable 1.78.0 to stable 1.85.0. No other workflow logic or public APIs changed. Changes
Sequence Diagram(s)sequenceDiagram
actor Runner as GitHub Runner
participant Step as "Install Tauri CLI" step
participant Cargo as cargo
Runner->>Step: start
Note right of Step: env CARGO_CFG_TARGET_OS=<linux|macos>
Step->>Cargo: CARGO_CFG_TARGET_OS=... cargo install tauri-cli
Cargo-->>Step: install result
Step-->>Runner: step complete
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
✨ Finishing Touches🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
flake.nix (1)
19-21: LGTM: Rust toolchain bumped to 1.85.0This aligns with the need for Edition 2024 support.
To avoid drift between devShell (Nix) and CI, consider pinning GitHub Actions to the same Rust version. For example, in your Install Rust steps:
- name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: 1.85.0 targets: aarch64-apple-ios # or other targets already present in each workflowIf you’d like, I can prepare a follow-up PR to pin these across all workflows.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (5)
.github/workflows/claude.yml(1 hunks).github/workflows/desktop-build.yml(1 hunks).github/workflows/mobile-build.yml(1 hunks).github/workflows/testflight-on-comment.yml(1 hunks)flake.nix(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build-ios
- GitHub Check: build-linux
- GitHub Check: Cloudflare Pages
🔇 Additional comments (3)
.github/workflows/desktop-build.yml (1)
130-131: LGTM: Correct OS override for Linux host installSetting CARGO_CFG_TARGET_OS=linux for the cargo install step matches the host OS on ubuntu-latest and aligns with the getrandom workaround.
.github/workflows/testflight-on-comment.yml (1)
104-105: Use ‘macos’ for the host override & verify iOS buildIn the “Install Tauri CLI” step, replace the current
darwinoverride withmacos(Rust’starget_osfor macOS hosts), and include the workaround comment:env: - CARGO_CFG_TARGET_OS: darwin + # Workaround for getrandom v0.2.16 (https://github.com/rust-random/getrandom/issues/641) + # cargo install builds for the host; on macOS runners target_os is "macos" + CARGO_CFG_TARGET_OS: macosNote that the “Build Tauri iOS App” job does not set
CARGO_CFG_TARGET_OS. If you see failures there, add:env: CARGO_CFG_TARGET_OS: iosPlease confirm whether the iOS build passes without that additional override.
.github/workflows/claude.yml (1)
113-113: LGTM: Correct Linux override for host installUsing CARGO_CFG_TARGET_OS=linux when installing tauri-cli on ubuntu-latest is appropriate and consistent with the workaround.
CodeRabbit correctly pointed out that Rust's cfg(target_os) uses 'macos' for macOS, not 'darwin'. Since cargo install builds tauri-cli for the host OS (macOS runners), we need to use 'macos'. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Greptile Summary
Note: This review covers only the changes made since the last review (commit 3ef7163), not the entire PR.
The recent changes implement the corrections identified in the previous review regarding the CARGO_CFG_TARGET_OS environment variable. The developer has updated two workflow files:
- mobile-build.yml: Changed
CARGO_CFG_TARGET_OSfrom 'darwin' to 'macos' in the Tauri CLI installation step - testflight-on-comment.yml: Applied the same correction, changing the value from 'darwin' to 'macos'
Both changes include proper documentation comments explaining this is a workaround for getrandom v0.2.16 compilation issues and clarifying that cargo install builds for the host platform, where macOS runners use 'macos' as the target_os identifier.
These changes are part of the broader effort to resolve build failures caused by the getrandom crate's platform detection issues. The corrections ensure that when Tauri CLI is installed via cargo install on macOS GitHub Actions runners, the getrandom crate and its dependencies can properly identify the platform and compile successfully. The changes maintain consistency with Rust's canonical cfg(target_os) values, where 'macos' is the correct identifier for macOS systems, not 'darwin'.
Confidence score: 5/5
- This PR is safe to merge with minimal risk
- Score reflects straightforward environment variable corrections that address a well-documented upstream issue
- No files require special attention as the changes are simple and well-documented
2 files reviewed, no comments
|
@TestFlight build |
|
🚀 TestFlight deployment triggered! Check the Actions tab for progress. |
|
✅ TestFlight deployment completed successfully! |
This addresses the issue where getrandom v0.2.16 fails to correctly detect the target platform, causing multiple module definition errors. See: rust-random/getrandom#641
🤖 Generated with Claude Code
Summary by CodeRabbit