You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve error message about the PackageGraphError.productDependencyNotFound (#7419)
Fixed a bug in the productDependencyNotFound error message
### Motivation:
fix#7398
The above issue suggests the following two defects.
1. package dependency resolution changes depending on the order of
packages (alphabetical order)
2. the phrase "Did you meen..." in the error message in the error
message is not on target.
### Modifications:
The first problem is as described in the issue, if users rename the
directory containing Package.swift from repro to zzz, the "Did you
meen..." will appear. will appear. Essentially, the error minutes should
be displayed in full, regardless of the name of the directory. This is
due to the fact that the loop used to resolve dependencies depends on
the alphabetical order of the directories and the side effect on
allTargetName inside the loop. Therefore, the side effect for
allTargetName inside the loop has been moved to the outside of the loop.
The second problem is that when dependency A of a package is not found,
a strange suggestion "Did you meen `A`? ", which is a strange
suggestion. This is because when a dependency is not found, the message
"Did you meen `<target name>`" is printed if there is a dependency with
a similar name (even the exact same name). Thus, if the names are the
same, "Did you meen `.product(name: ... , package:
"swift-argugument")"`" instead of the found target name.
### Result:
Command to execute:
`swift build`
Result of command:.
`error: 'repro': product 'ArgumentParser' required by package 'repro'
target 'repro' not found. Did you mean '.product(name: "ArgumentParser",
package: "swift-argument-parser")'?`
Condition:
The following steps were taken to create the environment.
1. mkdir repro
1. cd repro
1. swift package init --type executable
1. Open Package.swift and make sure it has this content:
```swift
// swift-tools-version: 5.10
import PackageDescription
let package = Package(
name: "repro",
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.3.0")
],
targets: [
.executableTarget(
name: "repro",
dependencies: ["ArgumentParser"]
)
]
)
```
---------
Co-authored-by: Yuta Saito <[email protected]>
return"product '\(dependencyProductName)' is declared in the same package '\(package)' and can't be used as a dependency for target '\(targetName)'."
236
236
}else{
237
237
vardescription="product '\(dependencyProductName)' required by package '\(package)' target '\(targetName)' \(dependencyPackageName.map{"not found in package '\($0)'"}??"not found")."
0 commit comments