Skip to content

Work around https://github.com/swiftlang/swift-foundation/issues/1125 #1169

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

Merged
merged 1 commit into from
Mar 14, 2025

Conversation

d-ronnqvist
Copy link
Contributor

Bug/issue #, if applicable: rdar://146539299 #1136

Summary

This works around swiftlang/swift-foundation#1125 for all the copy item operations that DocC does to avoid potential permission issues when copying file attributes over to the otherwise successfully copied items.

Dependencies

None.

Testing

Rephrased from #1136:

  • Install Swift to a system directory such as / or /usr/libexec/swift.
  • Run docc convert from the system directory.

The convert action should succeed, without permission error or other unexpected file write errors.

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • [ ] Added tests
  • Ran the ./bin/test script and it succeeded
  • [ ] Updated documentation if necessary Added in-source comments to explain the workaround.

@@ -39,7 +39,7 @@ package protocol FileManagerProtocol: DataProvider {
/// Returns `true` if a file exists at the given path.
func fileExists(atPath: String) -> Bool
/// Copies a file from one location on the file-system to another.
func copyItem(at: URL, to: URL) throws
func _copyItem(at: URL, to: URL) throws // Use a different name than FileManager to work around https://github.com/swiftlang/swift-foundation/issues/1125
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if there's a better name for this but I'd be happy to rename it if anyone has a better suggestion.

AFAIK it needs to be a different name than copyItem(at:to:) so that we can provide a custom implementation for FileManager that calls the real NSFileManager/copyItem(at:to:) without causing an infinite recursion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, we could spell it out like func copyItemWithWorkaround(at: URL, to: URL) or something like that.

@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

@d-ronnqvist d-ronnqvist linked an issue Mar 13, 2025 that may be closed by this pull request
2 tasks
Copy link
Contributor

@patshaughnessy patshaughnessy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@d-ronnqvist d-ronnqvist merged commit 1c37aeb into swiftlang:main Mar 14, 2025
2 checks passed
@d-ronnqvist d-ronnqvist deleted the work-around-copy-item-error branch March 14, 2025 10:38
xtremekforever pushed a commit to xtremekforever/swift-docc that referenced this pull request Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Permission issue when Swift toolchain/docc is installed as root user
2 participants