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
Unclear missing product error depends on ordering of package names #7398
Labels
Comments
MaxDesiatov
changed the title
Unclear missing product diagnostic message that also depends on ordering of package names
Unclear missing product error depends on ordering of package names
Mar 10, 2024
kateinoigakukun
added a commit
that referenced
this issue
Mar 30, 2024
…tFound (#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]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it reproducible with SwiftPM command-line tools:
swift build
,swift test
,swift package
etc?Description
When a product that a target depends on is missing, sometimes a diagnostic message is produced:
This could look up the name of the product in packages that this package depends on. Turns out, SwiftPM does do that, but only if package identity is sorted in a particular way. When names of packages in the graph are sorted alphabetically, the name of root package needs to precede the name of the package dependency that contains a candidate product for this error to appear:
In no way this error message is an improvement, as it suggests exactly the same spelling that caused the error in the first place. It should say "Did you mean
.product(name: "ArgumentParser", package: "swift-argument-parser")
" instead.Expected behavior
The diagnostic error message is helpful, actionable, and doesn't depend on ordering of names of packages participating in the dependencies graph.
Actual behavior
The error message is not helpful and also unexpectedly depends on ordering of package names in the graph.
Steps to reproduce
mkdir repro
cd repro
swift package init --type executable
Package.swift
and make sure it has this content:swift build
and observe this error:cd ..
mv repro zzz
cd zzz
swift build
and observe a confusing diagnostic message:Swift Package Manager version/commit hash
No response
Swift & OS version (output of
swift --version ; uname -a
)Xcode 15.3
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
Also reproducible with
swift-DEVELOPMENT-SNAPSHOT-2024-03-01-a-osx
.The text was updated successfully, but these errors were encountered: