Unable to build Xcode projects using SwiftPM in MacPorts sandbox
Hi, As I try to package the latest commit of poedit, I encountered the following error: Failed to determine if database is empty or not: Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “org.swift.swiftpm” in the folder “Caches”." UserInfo={NSFilePath=/opt/local/var/macports/home/Library/Caches/org.swift.swiftpm, NSUnderlyingError=0x6010daa0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}Failed to determine if database is empty or not: Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “org.swift.swiftpm” in the folder “Caches”." UserInfo={NSFilePath=/opt/local/var/macports/home/Library/Caches/org.swift.swiftpm, NSUnderlyingError=0x61e180c0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} I think it could be base's sandbox that prevented writes to the home directory, where SwiftPM stores its cache. Any ideas? -- Zero
Re: Unable to build Xcode projects using SwiftPM in MacPorts sandbox
On Mar 23, 2024, at 23:00, Zero King wrote: > > I think it could be base's sandbox that prevented writes to the home > directory, where SwiftPM stores its cache. If disabling sandboxing in macports.conf makes it work, then your suspicion is probably correct. MacPorts sets the HOME environment variable to point to a directory within workpath. It looks like it's ignoring that and trying to write to a subdirectory of the macports user's real home directory, /opt/local/var/macports/home. That would be a bug to file with Apple. It has been a long-standing problem that has affected MacPorts in other ways before.
Re: Unable to build Xcode projects using SwiftPM in MacPorts sandbox
Hi Ryan, On Sat, Mar 23, 2024 at 11:19:03PM -0500, Ryan Schmidt wrote: On Mar 23, 2024, at 23:00, Zero King wrote: I think it could be base's sandbox that prevented writes to the home directory, where SwiftPM stores its cache. If disabling sandboxing in macports.conf makes it work, then your suspicion is probably correct. Yes, it was the sandbox. I set `sandbox_enable no` and this error was gone. MacPorts sets the HOME environment variable to point to a directory within workpath. It looks like it's ignoring that and trying to write to a subdirectory of the macports user's real home directory, /opt/local/var/macports/home. That would be a bug to file with Apple. It has been a long-standing problem that has affected MacPorts in other ways before. SwiftPM seems to prefer the "idiomatic" cache directory, which is constructed from FileManager's .cachesDirectory that points to Library/Caches. https://github.com/apple/swift-tools-support-core/blob/930e82e5ae2432c71fe05f440b5d778285270bdb/Sources/TSCBasic/FileSystem.swift#L462 https://github.com/apple/swift-package-manager/blob/9d48dc70aab03a1824ee63abdf105212e08b1dbd/Sources/Basics/FileSystem/FileSystem%2BExtensions.swift#L241-L265 https://developer.apple.com/documentation/foundation/filemanager/searchpathdirectory/cachesdirectory I'm not sure whether to file this as a bug. At its root is the FileManager, but I doubt Apple would change its API. SwiftPM has a cache-path option that could be used to override the cache path, but I'm not sure how to use it in an Xcode project yet. -- Zero