diff --git a/Sources/Workspace/Diagnostics.swift b/Sources/Workspace/Diagnostics.swift index e0c27c0a36f..4a5bae98d7b 100644 --- a/Sources/Workspace/Diagnostics.swift +++ b/Sources/Workspace/Diagnostics.swift @@ -182,6 +182,10 @@ struct BinaryArtifactsManagerError: Error, CustomStringConvertible { .init(description: "local archive of binary target '\(targetName)' at '\(archivePath)' does not contain a binary artifact.") } + static func localArchiveNotFound(archivePath: AbsolutePath, targetName: String) -> Self { + .init(description: "local archive of binary target '\(targetName)' at '\(archivePath)' does not exist.") + } + static func localArtifactNotFound(artifactPath: AbsolutePath, targetName: String) -> Self { .init(description: "local binary target '\(targetName)' at '\(artifactPath)' does not contain a binary artifact.") } diff --git a/Sources/Workspace/Workspace+BinaryArtifacts.swift b/Sources/Workspace/Workspace+BinaryArtifacts.swift index d3c130708bb..7574a255fba 100644 --- a/Sources/Workspace/Workspace+BinaryArtifacts.swift +++ b/Sources/Workspace/Workspace+BinaryArtifacts.swift @@ -92,6 +92,15 @@ extension Workspace { // TODO: find a better way to get the base path (not via the manifest) let absolutePath = try manifest.path.parentDirectory.appending(RelativePath(validating: path)) if absolutePath.extension?.lowercased() == "zip" { + guard self.fileSystem.exists(absolutePath) else { + observabilityScope.emit( + BinaryArtifactsManagerError.localArchiveNotFound( + archivePath: absolutePath, + targetName: target.name + ) + ) + continue + } localArtifacts.append( .local( packageRef: packageReference, @@ -541,7 +550,7 @@ extension Workspace { ) } } catch { - let reason = (error as? LocalizedError)?.errorDescription ?? error.localizedDescription + let reason = error.interpolationDescription observabilityScope.emit(BinaryArtifactsManagerError.localArtifactFailedExtraction( artifactPath: artifact.path,