Uh oh!
There was an error while loading. Please reload this page.
Fix Linux build: replace fputs(_:stderr) with FileHandle.standardError - #441
Conversation
glibc declares `stderr` as `extern FILE *stderr` — a mutable global — so Swift 6 strict concurrency rejects any reference to it: MistDemo.swift:44:33: error: reference to var 'stderr' is not concurrency-safe because it involves shared mutable state Darwin's `stderr` is imported differently, so this only breaks the "Test MistDemo on Ubuntu" job in the Examples workflow; the macOS build is unaffected. The call was introduced in #429 (0b6bea9). Switch to `FileHandle.standardError.write(Data(...utf8))`, the idiom already used across MistDemoKit (LookupCommand, ModifyCommand, ModifyZonesCommand, MistDemoConfig+DatabaseConfiguration, …) and BushelCloudKit's ConsoleOutput. `internal import Foundation` was already present. No other file under Examples/ or Sources/ references `stderr` or `stdout` in code (remaining hits are doc comments and a test string). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xs1c8vvxjCxqZiStcmuPS2
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@## v1.0.0-beta.4 #441 +/- ##
=================================================
- Coverage 81.45% 81.39% -0.07%
=================================================
Files 191 191 Lines 4719 4719 =================================================
- Hits 3844 3841 -3 - Misses 875 878 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Uh oh!
There was an error while loading. Please reload this page.
The error
The
Examplesworkflow's Test MistDemo on Ubuntu job fails to compile:Why it is Linux-only
glibc declares the stream as
extern FILE *stderr— a plain mutable global — which Swift imports as a globalvar. Under Swift 6 strict concurrency, referencing a non-Sendable, non-isolated mutable global is an error.Darwin's headers expose
stderrdifferently (via__stderrp), and the Darwin overlay imports it in a form the concurrency checker accepts, so the exact same line compiles cleanly on macOS. That's why this got through review and the macOS jobs: it cannot reproduce locally on a Mac.The line was introduced in #429 (0b6bea9).
The fix
One-line change in
Examples/MistDemo/Sources/MistDemo/MistDemo.swift: write throughFileHandleinstead of the C stream.This is the idiom already used everywhere else in this codebase for stderr output —
MistDemoConfig+DatabaseConfiguration.swift,LookupCommand.swift,LookupAllRecordsCommand.swift,ModifyCommand.swift,ModifyZonesCommand.swift,DiscoverAllUserIdentitiesCommand.swift, andBushelCloudKit'sConsoleOutput— so the fix matches existing style rather than introducing a new pattern.internal import Foundationwas already present in the file, so no import change was needed (the repo's explicit-access-modifier import convention is preserved).I grepped all of
Examples/andSources/forstderr/stdout: this was the only code reference. Every other hit is a doc comment or a test asserting on help text, none of which touch the C globals. No other changes are included in this PR.Verification
swift buildinExamples/MistDemo(macOS, Swift 6.3)swift testinExamples/MistDemo(macOS)swift build+swift testat repo root (macOS)swiftlint --strict+swift-format lint --stricton the changed fileswift build—docker run --rm swift:6.3inExamples/MistDemo(same image the CI job uses)swift test— same containerLinux verification was actually performed, not assumed: the pre-fix error reproduces only on Linux, and the
swift:6.3container build now completes with exit code 0.Note on
LINT_MODE=STRICT ./Scripts/lint.sh: it reports 54 pre-existing violations on this base branch (file-name, type-contents-order, line-length, etc. acrossSources/,Tests/, andScripts/OpenAPITools/Package.swift). None are in the file this PR touches, and the count is unchanged by this PR —Scripts/lint.shdoesn't even scanExamples/. Worth flagging separately: when$CIis unset,lint.shrunsswift-format --in-placeandswiftlint --fixregardless ofLINT_MODE, so running it locally rewrites unrelated files (and the locally-resolved swift-format disagrees with the pinned one). That's out of scope here.🤖 Generated with Claude Code