Skip to content

Commit 07b0fb5

Browse files
committed
Test parent directory of .netrc file is writable before using it
https://ci.swift.org/job/swift-PR-source-compat-suite-debug/4058/ ``` $ sandbox-exec -f /Users/buildnode/jenkins/workspace-private/swift-source-compat-suite-sandbox/sandbox_package.sb /Users/buildnode/jenkins/workspace-private/swift-PR-source-compat-suite-debug/build/compat_macos/install/toolchain/usr/bin/swift package --disable-sandbox -C /Users/buildnode/jenkins/workspace/swift-PR-source-compat-suite-debug/swift-source-compat-suite/project_cache/GRDB.swift clean warning: '--chdir/-C' option is deprecated; use '--package-path' instead warning: Failed to load .netrc file at /Users/buildnode/.netrc. Error: unreadableFile(<AbsolutePath:"/Users/buildnode/.netrc">) error: other(1) ``` Not sure if the `other(1)` error is `.netrc` related. Trying to see if this code change will fix it. rdar://88308095
1 parent f517ff5 commit 07b0fb5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Sources/Commands/SwiftTool.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,13 @@ public class SwiftTool {
609609
// User didn't tell us to use these .netrc files so be more lenient with errors
610610
func loadNetrcNoThrows(at path: AbsolutePath) -> NetrcAuthorizationProvider? {
611611
guard localFileSystem.exists(path) else { return nil }
612+
613+
do {
614+
try withTemporaryFile(dir: path.parentDirectory) { _ in }
615+
} catch {
616+
self.observabilityScope.emit(warning: "\(path.parentDirectory) is not accessible or not writable, not using .netrc file in it: \(error)")
617+
return nil
618+
}
612619

613620
do {
614621
return try NetrcAuthorizationProvider(path: path, fileSystem: localFileSystem)

0 commit comments

Comments
 (0)