When executing XCTest through GitLab CI, you may encounter the following error.
/Library/Ruby/Gems/2.6.0/gems/xcpretty-0.3.0/lib/xcpretty/parser.rb:434:in `===': invalid byte sequence in US-ASCII (ArgumentError)
from /Library/Ruby/Gems/2.6.0/gems/xcpretty-0.3.0/lib/xcpretty/parser.rb:434:in `update_test_state'
from /Library/Ruby/Gems/2.6.0/gems/xcpretty-0.3.0/lib/xcpretty/parser.rb:307:in `parse'
from /Library/Ruby/Gems/2.6.0/gems/xcpretty-0.3.0/lib/xcpretty/formatters/formatter.rb:88:in `pretty_format'
from /Library/Ruby/Gems/2.6.0/gems/xcpretty-0.3.0/lib/xcpretty/printer.rb:19:in `pretty_print'
from /Library/Ruby/Gems/2.6.0/gems/xcpretty-0.3.0/bin/xcpretty:84:in `block in <top (required)>'
from /Library/Ruby/Gems/2.6.0/gems/xcpretty-0.3.0/bin/xcpretty:83:in `each_line'
from /Library/Ruby/Gems/2.6.0/gems/xcpretty-0.3.0/bin/xcpretty:83:in `<top (required)>'
from /usr/local/bin/xcpretty:23:in `load'
from /usr/local/bin/xcpretty:23:in `<main>'
2022-06-28 19:15:17.149 xcodebuild[28965:188047] NSFileHandle couldn't write. Exception: *** -[_NSStdIOFileHandle writeData:]: Broken pipeThis article will guide you through resolving this issue.
Error Cause
This error occurs when xcpretty fails to process a string from the xcodebuild log output, causing xcpretty to crash and preventing xcodebuild from outputting the log.
Solution
You can address this issue by properly setting the locale for gitlab-runner. Follow the steps below.
(1) Open the ~/Library/LaunchAgents/gitlab-runner.plist file.
(2) Add the EnvironmentVariables as follows.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- omission -->
<key>EnvironmentVariables</key>
<dict>
<key>LC_ALL</key>
<string>en_US.UTF-8</string>
</dict>
</dict>Restart your machine, or you can relaunch the gitlab-runner as show below.
gitlab-runner stop
gitlab-runner start










