Command PhaseScriptExecution failed with a nonzero exit code
New Issue Checklist
- [x] I've Updated SwiftLint to the latest version.
- [x] I've searched for existing GitHub issues.
Bug Description
We've been using the following script in build phase for the past 3 years.
if [[ "$(uname -m)" == arm64 ]]
then
export PATH="/opt/homebrew/bin:$PATH"
fi
if which swiftlint >/dev/null; then
swiftlint --fix && swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
exit 1
fi
Everything works until yesterday. The build failed at the script execution, and here is the error
Then we have to put project folder and unit test folders explicitly under included: section in .swiftLint.yml to get the project build.
I am not sure this is the issue of swiftlint or datadog or both but it seems quit similar to this issue https://github.com/realm/SwiftLint/issues/4127, which was posted 3 years ago.
Environment
- SwiftLint version: 0.59.1
- Xcode version: Xcode 16.0, Build version 16A242d
- Installation method used (Homebrew)
- Configuration file:
disabled_rules:
- statement_position # https://realm.github.io/SwiftLint/statement_position.html
- colon
- nesting
- line_length
- identifier_name
- multiple_closures_with_trailing_closure
- cyclomatic_complexity
- function_body_length
- type_name
- file_length
- type_body_length
- function_parameter_count
- large_tuple
- redundant_discardable_let
- for_where
included:
- [PROJECT_FOLDER]
- [UNIT_TEST_FOLDER]
- [UI_TEST_FOLDER]
excluded:
- Packages/[SOME_PACKAGE_FILE]
What has changed in your setup? The Xcode or SwiftLint version? More files being linted? I doubt that it suddenly stopped working. If so, I wouldn't suspect SwiftLint.
Looks like the last file before the crash is located in a checkout directory. Is it supposed to be analyzed? Can you make sure, linting it isolatedly works?
What has changed in your setup? The Xcode or SwiftLint version? More files being linted? I doubt that it suddenly stopped working. If so, I wouldn't suspect SwiftLint.
Nothing has changed, the same script in build phase, we did add another test plan (only test plan, reuse existing scheme) and other stuff needed to setup Github Actions, but I think that's unrelated because, I checked out an older commit which released a few weeks back and it failed for the same reason (with upgraded swiftLint 0.59.1)
Looks like the last file before the crash is located in a
checkoutdirectory. Is it supposed to be analyzed?
I was not the person who originally setup the swiftLint. It's not supposed to be checked but that's the setting previously used and SwiftLink worked well with that. If it was not for this failure, I wouldn't realized the settings we have been used for the past 3 years even check the source
Can you make sure, linting it isolatedly works? I answered in the OP, yes it works, cuz the error is gone after added
includedsection in the.ymlfile
My assumption would be that dependencies changed and now there's a source file causing SwiftLint to crash. With the explicit includes, you skip linting external code now and that fixes it. Would be interesting to isolate the file causing the crash … Other than that, I have no clue what could have caused that.
I encountered this when updating from SwiftLint 0.56.1 to 0.59.1 (via the plugin). I found that 0.57.1 and earlier worked for my project, but 0.58.0 onwards would fail with "Command PhaseScriptExecution failed with a nonzero exit code". I figure this has to do with one of the breaking changes listed in 0.58.0, at least for my case.