Skip to content
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

Use Local Version -- Case Sensitivity Problems #7931

Closed
samdeane opened this issue Aug 29, 2024 · 6 comments · Fixed by #7941
Closed

Use Local Version -- Case Sensitivity Problems #7931

samdeane opened this issue Aug 29, 2024 · 6 comments · Fixed by #7941
Assignees
Labels

Comments

@samdeane
Copy link

samdeane commented Aug 29, 2024

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 called Versionator.

Performing this step results in the following error:

image

To Reproduce

Clone git@github.com:elegantchaos/VersionatorTest
Checkout commit b5ffdc1354d68b46fc65793d8acea8e59eab163e
Clone git@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 Versionator

Expected behavior

The Versionator package should be set into edit mode, pointing at the local checkout

Environment

~/Developer/Projects/VersionatorTest > versions                                                                                                                                       (main)
+ uname
Darwin
+ sw_vers
ProductName:            macOS
ProductVersion:         14.6.1
BuildVersion:           23G93
+ swift --version
swift-driver version: 1.113 Apple Swift version 6.0 (swiftlang-6.0.0.7.6 clang-1600.0.24.1)
Target: arm64-apple-macosx14.0
+ xcodebuild -version
Xcode 16.1
Build version 16B5001e
+ code --version
1.92.2
fee1edb8d6d72a0ddff41e5f71a671c23ed924b9
arm64

Additional context

Running swift package edit Versionator --path ../Versionator myself from the terminal does work.

@samdeane samdeane added the bug label Aug 29, 2024
@michael-weng
Copy link

I will take a look at this.

@michael-weng
Copy link

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.

@award999 award999 transferred this issue from swiftlang/vscode-swift Aug 29, 2024
@bripeticca bripeticca self-assigned this Aug 29, 2024
@bripeticca
Copy link
Contributor

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.

@nmggithub
Copy link

(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?

@bripeticca
Copy link
Contributor

(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.

@bripeticca
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants