Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode 15 Beta 8 + Xcode Cloud Error #5205

Closed
2 tasks done
dcilia opened this issue Sep 5, 2023 · 17 comments
Closed
2 tasks done

Xcode 15 Beta 8 + Xcode Cloud Error #5205

dcilia opened this issue Sep 5, 2023 · 17 comments
Labels
integration Issues related to integration of SwiftLint into toolchains.

Comments

@dcilia
Copy link

dcilia commented Sep 5, 2023

New Issue Checklist

Describe the bug

Hello. We are utilizing the SwiftLint plugin as a build phase in our project containing:

  • iOS App Target
  • iOS App Clip Target

When building with Xcode Cloud using Xcode Beta (8 in this case) a build error is encountered related to SwiftLint.

2023-09-05T18:13:05.391803418Z	2023-09-05 11:12:56.500 xcodebuild[10687:38398]  DVTFilePathFSEvents: Failed to start fs event stream.
2023-09-05T18:13:05.391812273Z	Error: You don’t have permission to save the file “f50a50e51ef5bdd780b98209347c4360c491f7299bcc424e3316162e78de3c24.plist” in the folder “478B1767-7422-3827-9D90-A09D769C708F”.
2023-09-05T18:13:05.391819938Z	
2023-09-05T18:13:05.391824842Z	/usr/bin/sandbox-exec -p "(version 1)
2023-09-05T18:13:05.391830105Z	(deny default)
2023-09-05T18:13:05.391849244Z	(import \"system.sb\")
2023-09-05T18:13:05.391854386Z	(allow file-read*)
2023-09-05T18:13:05.391859099Z	(allow process*)
2023-09-05T18:13:05.391863573Z	(allow file-write*
2023-09-05T18:13:05.391886045Z	    (subpath \"/private/tmp\")
2023-09-05T18:13:05.391896318Z	    (subpath \"/private/var/folders/x7/fs459gdd67132_hw5t3cz_s00000gn/T\")
2023-09-05T18:13:05.391913502Z	)
2023-09-05T18:13:05.391918327Z	(deny file-write*
2023-09-05T18:13:05.391923035Z	    (subpath \"/Volumes/workspace/repository\")
2023-09-05T18:13:05.391928353Z	)
2023-09-05T18:13:05.391933923Z	(allow file-write*
2023-09-05T18:13:05.391938967Z	    (subpath \"/Volumes/workspace/DerivedData/SourcePackages/plugins/**REDACTED**.output/**REDACTED**/SwiftLintPlugin\")
2023-09-05T18:13:05.453548242Z	2023-09-05 11:12:56.602 xcodebuild[10689:38404]  DVTFilePathFSEvents: Failed to start fs event stream.
2023-09-05T18:13:05.453557706Z	Error: You don’t have permission to save the file “f50a50e51ef5bdd780b98209347c4360c491f7299bcc424e3316162e78de3c24.plist” in the folder “478B1767-7422-3827-9D90-A09D769C708F”.

Additionally, our ci_post_clone script contains defaults write com.apple.dt.Xcode IDESkipPackagePluginFingerprintValidatation -bool YES

Xcode Cloud Environment is set to:

  • Latest or Beta Release Xcode
  • Latest or Beta Release macOS
Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint

Environment

  • SwiftLint version (run swiftlint version to be sure)?
  • Installation method used (Homebrew, CocoaPods, building from source, etc)?
  • Paste your configuration file:
# insert yaml contents here
  • Are you using nested configurations?
    If so, paste their relative paths and respective contents.
  • Which Xcode version are you using (check xcodebuild -version)?
  • Do you have a sample that shows the issue? Run echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
    to quickly test if your example is really demonstrating the issue. If your example is more
    complex, you can use swiftlint lint --path [file here] --no-cache --enable-all-rules.
// This triggers a violation:
let foo = try! bar()
@Timac
Copy link

Timac commented Sep 13, 2023

We are seeing the same issue with Xcode 15 RC (15A240d) and macOS Sonoma 14 RC (23A339) on Xcode Cloud.

@jdelaune
Copy link

Facing the same issue.

Doesn't matter if we use different macOS versions so must be something in Xcode 15.

@mrgrauel
Copy link

mrgrauel commented Sep 18, 2023

I'm also facing the same issue. I have Swiftlint installed via SPM.
It works locally but not on Xcode Cloud.

You don’t have permission to save the file “6b5aa8591b5cebd1642ae2931fe1713c07f393dec2c52745c43228f2d2b79409.plist” in the folder “478B1767-7422-3827-9D90-A09D769C708F”.

@KoCMoHaBTa
Copy link

Same issue here

@SimplyDanny SimplyDanny added the integration Issues related to integration of SwiftLint into toolchains. label Sep 19, 2023
@phranck
Copy link

phranck commented Sep 26, 2023

Same issue here

@honus
Copy link

honus commented Sep 29, 2023

Ran into this as well. The only way I could get it to work was to hack swiftlint so isLikelyXcodeCloudEnvironment always returned true (and jump through the hoops to host my own binary of it). I couldn't figure out how to get logs out of it when running on Xcode Cloud so I'm not sure why that function isn't returning true when it should. As far as I can tell all the right things are in the environment.

Edited to add: I thought I had tried this before but I guess it failed for a different reason. But changing SwiftLintPlugin to pass "--no-cache" as an argument also is sufficient to fix the problem, further evidence, I think, that isLikelyXcodeCloudEnvironment is no longer able to correctly detect Xcode Cloud builds.

@simba909
Copy link

simba909 commented Sep 29, 2023

@honus This made me think about and look at the docs for Xcode Cloud environment variables, at which point I noticed this entry that I don't think I've seen before:

CI_XCODE_CLOUD
A Boolean value that evaluates to TRUE when the custom build script runs in Xcode Cloud. Use it to only run the script content when Xcode Cloud builds your project or workspace.

Still haven't looked at why isLikelyXcodeCloudEnvironment isn't working (which it still should, I think) but maybe it could be simplified now with the new(?) variable? 🤔

@honus
Copy link

honus commented Oct 5, 2023

Could be. I haven't figured out how to get logs out of swiftlint running in Xcode Cloud so it is hard to diagnose.

@GeekOnIce
Copy link

GeekOnIce commented Oct 9, 2023

Having this problem as well, and I'm guessing the reason that isLikelyXcodeCloudEnvironment is no longer working has something to do with the CI_WORKSPACE environment variable it references being deprecated. In my custom scripts that I haven't had a chance to update yet, I'm seeing the following warning: Found usage of deprecated environment variable CI_WORKSPACE. Use CI_PRIMARY_REPOSITORY_PATH instead

It doesn't quite make sense why isLikelyXcodeCloudEnvironment would fail due to this deprecation though - from everything I can see that environment variable is still set, and the isLikelyXcodeCloudEnvironment simply checks for it's existence - but it does seem a bit too coincidental to not be related.

@piotrtobolski
Copy link

Same issue here, is there any easy workaround for this?

@KoCMoHaBTa
Copy link

I've switched to using the binary by committing it into the project repository and running it as part of a build phase script. It works fine as long as ENABLE_USER_SCRIPT_SANDBOXING is disabled.

slavikus pushed a commit to evehome/SwiftLint that referenced this issue Oct 18, 2023
…e Cloud

In Xcode Cloud environment, SwiftLint’s cache cannot be written. When using the SwiftLinkPlugin, there is no way to disable the cache. Previously, a solution was made for the SwiftLint CLI itself where it looks at a set of environment variables (realm#4485). This solution offers a cleaner approach where the plugin itself decides whether it needs to enable or disable the cache based on the `CI_XCODE_CLOUD` environment variable.
@merichle
Copy link

merichle commented Oct 21, 2023

I have same issue on Xcode Cloud.

  • Xcode 15.0.1 RC (15A507)
  • macOS Sonoma 14.1 RC (23B73)
  • SwiftLint 0.53.0
xcodebuild[8854:31114]  DVTFilePathFSEvents: Failed to start fs event stream.
Error: You don’t have permission to save the file “0c1061be49c8d9a08abc57a1d1d91818db5ea359427cb0747c74b61d4fb20b86.plist” in the folder “EE88B62F-83D8-3E14-99E8-23B5D4B2F412”.

@piotrtobolski
Copy link

Any news about this issue?

po-gl added a commit to po-gl/Pomodoro that referenced this issue Nov 1, 2023
@SimplyDanny
Copy link
Collaborator

Fixed by #5287.

@jaredsinclair
Copy link

jaredsinclair commented Jan 31, 2024

This issue does not appear to have been fully resolved by #5287. I'm encountering the following error today:

v - Prepare Packages
vv - Running SwiftLint for MyApp 16.0 seconds

/usr/bin/sandbox-exec -p "(version 1)
(deny default)
(import \"system.sb\")
(allow file-read*)
(allow process*)
(allow mach-lookup (global-name \"com.apple.lsd.mapdb\"))
(allow file-write*
    (subpath \"/private/tmp\")
    (subpath \"/private/var/folders/lz/kwk55s8n75j_r0ckr6m6qj9h0000gn/T\")
)
(deny file-write*
    (subpath \"/Volumes/workspace/repository/MyApp\")
)
(allow file-write*
    (subpath \"/Volumes/workspace/DerivedData/SourcePackages/plugins/MyApp.output/MyApp/SwiftLint\")
)
" /Volumes/workspace/DerivedData/SourcePackages/artifacts/MyPrivatePackage/SwiftLintBinary/SwiftLintBinary.artifactbundle/swiftlint-0.54.0-macos/bin/swiftlint lint --strict --quiet --config /Volumes/workspace/repository/MyApp/.swiftlint.yml --cache-path /Volumes/workspace/DerivedData/SourcePackages/plugins/MyApp.output/MyApp/SwiftLint

2024-01-31 09:42:24.142 xcodebuild[6350:24748]  DVTFilePathFSEvents: Failed to start fs event stream.
2024-01-31 09:42:24.447 xcodebuild[6353:24760]  DVTFilePathFSEvents: Failed to start fs event stream.
2024-01-31 09:42:25.584 xcodebuild[6358:24778]  DVTFilePathFSEvents: Failed to start fs event stream.
Error: You don’t have permission to save the file “26c6d282529428ce0cf1ecf2295388c5f0fb2580bd42d99096ebb8d3b99f4da4.plist” in the folder “4D4FAECE-7849-3B2C-9674-8DDA23306B7E”.

Bug

I'm seeing SwiftLint 0.54 attempt to write to the file system despite the fact that the tool is running in Xcode Cloud. This causes an unrecoverable error preventing the rest of the build process.

Setup:

  • SwiftLint 0.54 binary release
  • SwiftLint is included as a binary dependency of an internal Swift package MyPrivatePackage
  • Project target relies on MyPrivatePackage's copy of SwiftLint as a build plugin step under a "Run Build Tool Plugins" Xcode build phase.
  • Xcode Cloud (set to "Latest Release" tooling)
  • A ci_post_checkout.sh Xcode Cloud script runs the following commands prior to resolving Swift packages or running build plugins:
defaults write com.apple.dt.Xcode IDESkipPackagePluginFingerprintValidatation -bool YES
defaults write com.apple.dt.Xcode IDESkipMacroFingerprintValidation -bool YES

Xcode Cloud Environment

The Xcode Cloud environment variables during Xcode Cloud's "Set environment variables" build step are:

CI=TRUE
CI_BRANCH=feature/jared/my-branch-name
CI_BUILD_ID=4a399832-e8ee-45cb-970a-350c55b478ce
CI_BUILD_NUMBER=21
CI_BUILD_URL=[REDACTED]
CI_BUNDLE_ID=[REDACTED]
CI_COMMIT=[REDACTED]
CI_DERIVED_DATA_PATH=/Volumes/workspace/DerivedData
CI_GIT_REF=refs/heads/feature/jared/my-branch-name
CI_PRIMARY_REPOSITORY_PATH=/Volumes/workspace/repository
CI_PRODUCT=MyApp
CI_PRODUCT_ID=[REDACTED]
CI_PRODUCT_PLATFORM=iOS
CI_PROJECT_FILE_PATH=/Volumes/workspace/repository/MyApp/MyApp.xcworkspace
CI_PULL_REQUEST_HTML_URL=[REDACTED]
CI_PULL_REQUEST_NUMBER=12345
CI_PULL_REQUEST_SOURCE_BRANCH=feature/jared/my-branch
CI_PULL_REQUEST_SOURCE_COMMIT=[REDACTED]
CI_PULL_REQUEST_SOURCE_REPO=[REDACTED]
CI_PULL_REQUEST_TARGET_BRANCH=feature/jared/my-branch-name
CI_PULL_REQUEST_TARGET_COMMIT=[REDACTED]
CI_PULL_REQUEST_TARGET_REPO=[REDACTED]
CI_RESULT_BUNDLE_PATH=/Volumes/workspace/resultbundle.xcresult
CI_START_CONDITION=pr_update
CI_TEAM_ID=[REDACTED]
CI_TEST_PLAN=AllTests
CI_TEST_PRODUCTS_PATH=/Volumes/workspace/TestProducts.xctestproducts
CI_WORKFLOW=PR Validation
CI_WORKSPACE_PATH=/Volumes/workspace
CI_XCODEBUILD_ACTION=build-for-testing
CI_XCODE_CLOUD=TRUE
CI_XCODE_PROJECT=MyApp.xcworkspace
CI_XCODE_SCHEME=MyApp
TMPDIR=/Volumes/workspace/tmp/

@jaredsinclair
Copy link

I filed the above as a new issue (#5448) because I believe the package plugin variant of using SwiftLint may have been overlooked during the earlier fixes for Xcode Cloud.

@SimplyDanny
Copy link
Collaborator

I filed the above as a new issue (#5448) because I believe the package plugin variant of using SwiftLint may have been overlooked during the earlier fixes for Xcode Cloud.

#5287 has only been done for package plugins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration Issues related to integration of SwiftLint into toolchains.
Projects
None yet
Development

No branches or pull requests