Open ahoppen opened 4 years ago
cc @hartbit
What do you think of the following diagnostics?
error: target 'testpackage' depends on an unknown package 'SwiftSyntax'; if the package is named differently from the product, either use '.product(name: "SwiftSyntax", package: <package-name>)' to specify the package name or give the package the 'SwiftSyntax' name using '.package(name: "SwiftSyntax", ...)'
@swift-ci create
I don’t know if that’s possible but could you, if you can’t find the package name based on the Git repository name, look into all packages and scan their package names for the name that was used in `dependencies`? That way you could provide a nice fix-it that specifies the package name.
Or, different strategy: If there’s a Git repository listed whose name doesn’t match the package name you can’t use it as a dependency AFAICT. So you could just offer a fixit adding `name: \<the package name>`.
I don’t know if that’s possible but could you, if you can’t find the package name based on the Git repository name, look into all packages and scan their package names for the name that was used in `dependencies`? That way you could provide a nice fix-it that specifies the package name.
That's something we could (and probably should) do in the long run, but it requires a fair amount of work. I think we should start by improving the diagnostic. What do you think of the one I suggested?
I agree with David, let's start by improving the diagnostics without automatically looking up the package name from the repository.
OK, sounds good to me. The improved diagnostic definitely gives a lot better idea of what’s going on.
Reopening because we should also fill in package name in the diagnostic.
I just ran into this issue testing out https://github.com/apple/swift-crypto/. Interestingly, this works in tools version 5.1, but gives the "unknown package error" in 5.2:
.target(name: "foo", dependencies: ["Crypto"]),
Can you try with the latest snapshot? You should see a much better error.
@aciidb0mb3r Just confirming that I do see the improved error message on a recent toolchain. Thanks.
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Package Manager | |Labels | Improvement | |Assignee | @hartbit | |Priority | Medium | md5: 832567a75e77933899a45288f49e4e50Issue Description:
If I try to depend on SwiftSyntax (package name `SwiftSyntax`, Git repository name `swift-syntax`), I used to write:
Doing the same with Swift 5.2 gives me the ambiguous error message
SwiftPM should tell me that I need to specify
name: "SwiftSyntax"
in the declaration of the dependency.