Use of unresolved identifier 'Self' in PackageDescription4Loader.swift

Hi all,

First of all, my excuses if this has already been posted, but I couldn't find anything related quickly. I'm trying to build sourcekit-lsp on Ubuntu 18.10, but am getting the following error:

swift build -Xcxx -I/usr/local/bin/swift-5.0.1-RELEASE-ubuntu18.04/usr/lib/swift/ -Xcxx -I/usr/local/bin/swift-5.0.1-RELEASE-ubuntu18.04/usr/lib/swift/Block/
/media/tdjg/Data1/Programming/sourcekit-lsp/.build/checkouts/swift-package-manager/Sources/PackageLoading/PackageDescription4Loader.swift:142:26: error: use of unresolved identifier 'Self'
            let groups = Self.invalidValueRegex.matchGroups(in: item).flatMap{ $0 }
                         ^~~~
/media/tdjg/Data1/Programming/sourcekit-lsp/.build/checkouts/swift-package-manager/Sources/PackageLoading/PackageDescription4Loader.swift:142:26: note: did you mean 'self'?
            let groups = Self.invalidValueRegex.matchGroups(in: item).flatMap{ $0 }
                         ^~~~
                         self
SPMUtility.Shell:1:13: note: did you mean 'Shell'?
public enum Shell : String, StringEnumArgument {

I've been trying to solve it but couldn't, any idea what it could be?
Btw, I've found a related stackoverflow post (unsolved) here:

kind regards,

Tim

Self is only available in Swift 5.1, which is not released yet. I don’t think SourceKitLSP existed at the time of Swift 5.0.1, so you cannot just check out an older revision. (At least I do not see the usual evidence of 5.0.x in its repository, such as a swift-5.0-branch.)

To build it, you will need a recent development snapshot of Swift. You can download them here.

(This sort of question belongs in the Using Swift category. Development is intended for discussions about the development of Swift, not development with Swift.)

1 Like

sourcekit-lsp has actually existed since before the release of Swift 5; it's just that it tends to rely on newer features found in development snapshots since it's somewhat "cutting-edge."

1 Like

I do see that the commit history is older than Swift 5. But there is no swift-5.0.1-REALEASE tag. Nor is there a swift-5.0-branch.

So what revision should Tim use to match the state it was in at Swift 5.0.1?

I'm uncertain if there's any patch that would work for sure. One thing that could be tried is picking a development snapshot (non-5.1) close to the Swift 5 release. That's not guaranteed to work, however. The best option is probably to install the latest Ubuntu development snapshot and build using that.

Hi all,

thanks for the pointers!! I will try to check out an older development snapshot first then. I have it working here on my desktop machine, compiled it back a month or so ago, but at the work laptop I tried to build it yesterday and it didn't work. Will see if I can find which snapshot I checked out on my desktop machine.

kind regards,

Tim

p.s. sorry if this post landed in the wrong category, I'm new to the forum but I also saw a lot of related posts in the sourcekit-lsp category, that's why I posted here.

Just to clarify this point: you need to have a sourcekit-lsp version that matches the toolchain. We don't go out of our way to break using older/newer toolchains, but we cannot always keep it working either, because we need to have a libSwiftPM that matches the toolchain.

Right now we support using the latest 5.1 toolchain with the swift-5.1-branch of sourcekit-lsp, or the latest master with the master branch of sourcekit-lsp. If for some reason you need a version that works with a specific toolchain snapshot, you can checkout the matching tag of sourcekit-lsp.

We don't have a tag for 5.0, because sourcekit-lsp was only being tested against swift master during this time. There may be some old enough version that will work, but there are no guarantees. To make a proper 5.0 version of sourcekit-lsp you would need to get sourcekit-lsp working with the swift-package-manager dependency set to a 5.0 version.

No worries. Almost everyone makes that mistake the first time.

Hey all,

thanks for the help. I've managed to build an older version of the toolchain. Like I said, I built this older version with success on another system. The version I managed to build with swift 5.01 is the one from the swift-DEVELOPMENT-SNAPSHOT-2019-02-19-a tag. I haven't tried a later version yet, but I'm happy this works. Hope anyone looking to solve this problem can fix it with this solution,

kind regards,

Tim

P.s. Sorry for the late reply, because of some time pressure I switched temporarily to my iMac and XCode.