Closed samdeane closed 2 months ago
I will take a look at this.
There's a discrepancy between how case is being handle as an identifier/name in swift package manager, I will forward this issue to spm project and let their contributors decide the best course of action.
Seems like there is a discrepancy between how SwiftPM is saving package identities (where it's forced to be lowercased via the PackageIdentityParser
initializers) and the logic for when a user invokes the swift package edit <package-name>
command - the command makes a comparison between the package name argument to the manifest identity as-is, without considering case insensitivity.
(where it's forced to be lowercased via the
PackageIdentityParser
initializers)
How is it being "forced" in this context? Does SwiftPM actually need to lowercase the identities, or is that just convention?
(where it's forced to be lowercased via the
PackageIdentityParser
initializers)How is it being "forced" in this context? Does SwiftPM actually need to lowercase the identities, or is that just convention?
When initializing a PackageIdentity
property (essentially just a wrapper structure that holds onto the string), it will automatically lowercase the string upon assignment in the initializers that are being called in SwiftPM. There is little documented as to why from what I've been able to see, so it seems this is unspoken convention.
Further investigation revealed that SwiftPM has two naming conventions for a package, one being the package identity and the other being the display name. The display name is intended to be used in UI as the name suggests, whereas referring to a package in all other cases should rely on the identity - including swift package command line arguments.
The identity is created through parsing the URL of the package's repository (namely just picking off the end of the path and removing .git
), and is then lowercased. The display name is specified in the package's manifest with the name
parameter, like such:
let package = Package(
name: "MyDisplayName",
// ...etc.
)
There are some discrepancies within SwiftPM between its usage of the two, so I think an effort to be more clear on which is expected on the user's end would be a great help here.
Describe the bug
Selecting
Use Local Version
for a package dependency is failing for me.I suspect that the problem relates to case sensitivity.
The VS Code Package Dependencies window shows the dependency name as
versionator
. The Package.swift file for dependency declares the package name as "Versionator". The local directory for the package is calledVersionator
.Performing this step results in the following error:
To Reproduce
Clone
git@github.com:elegantchaos/VersionatorTest
Checkout commit b5ffdc1354d68b46fc65793d8acea8e59eab163e Clonegit@github.com:elegantchaos/Versionator
to a parallel directory Open VersionatorTest in vscode Right click on versionator in the Package Dependencies list Choose Use Local Version select the local version of VersionatorExpected behavior
The Versionator package should be set into edit mode, pointing at the local checkout
Environment
Additional context
Running
swift package edit Versionator --path ../Versionator
myself from the terminal does work.