-1

I am trying to build sourcekit-lsp on my Ubuntu WSl. Successfully installed swift swift-5.2.5-RELEASE-ubuntu20.04

amal@DESKTOP-CJJEUS7:~/sourcekit-lsp$swift --version
Swift version 5.2.5 (swift-5.2.5-RELEASE)
Target: x86_64-unknown-linux-gnu

And also clone sourcekit-lst from master branch, Installed both sudo apt install libsqlite3-dev libncurses5-dev, followed every step from documentation, But at the time of building i got this error.

swift build -Xcxx -I/home/amal/swift-5.2.5-RELEASE-ubuntu20.04/usr/lib/swift -Xcxx -I/home/amal/swift-5.2.5-RELEASE-ubuntu20.04/usr/lib/swift/Block

/home/amal/sourcekit-lsp/.build/checkouts/swift-package-manager/Sources/PackageLoading/ManifestLoader.swift:530:55: error: type 'JSONEncoder.OutputFormatting' has no member 'withoutEscapingSlashes' encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes]
/home/amal/sourcekit-lsp/.build/checkouts/swift-package-manager/Sources/PackageLoading/ManifestLoader.swift:530:55: error: type 'JSONEncoder.OutputFormatting' has no member 'withoutEscapingSlashes' encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes]
/home/amal/sourcekit-lsp/.build/checkouts/swift-package-manager/Sources/PackageLoading/ManifestLoader.swift:530:55: error: type 'JSONEncoder.OutputFormatting' has no member 'withoutEscapingSlashes' encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes]
[137/214] Compiling Statistic.cpp

Any idea what i have done wrong? Please help.

Amalendu Kar
  • 458
  • 1
  • 6
  • 17

1 Answers1

1

when it fails silently like this it is usually because you are missing some of the dependencies. make sure that you install all

sudo apt-get install curl clang libicu-dev git libatomic1 libxml2 \
libcurl4 zlib1g-dev libbsd0 tzdata libssl-dev libsqlite3-dev \
libblocksruntime-dev libncurses5-dev libicu-dev libblocksruntime-dev \
libpthread-workqueue-dev -y

i was then still failing on main branch of sourcekit-lsp with error

/home/rock64/Software/sourcekit-lsp/.build/checkouts/swift-package-manager/Sources/PackageLoading/ManifestLoader.swift:548:55: error: type 'JSONEncoder.OutputFormatting' has no member 'withoutEscapingSlashes'
            encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes]
                                                     ~^~~~~~~~~~~~~~~~~~~~~~

but changing to a locally cloned swift-package-manager helped with the compilation. i have just altered the dependencies at the end of Package.swift file in sourcekit-lsp project to source the local spm like this

if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
  // Building standalone.
  package.dependencies += [
    .package(name: "IndexStoreDB", url: "https://github.com/apple/indexstore-db.git", .branch("main")),
    //.package(name: "SwiftPM", url: "https://github.com/apple/swift-package-manager.git", .branch("main")),
    .package(name: "SwiftPM", path: "/home/rock64/Software/swift-package-manager"),
    .package(url: "https://github.com/apple/swift-tools-support-core.git", .branch("main")),
    .package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "0.3.0")),
  ]
} else {
⋮

and removed the failing enum case encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes] in file

swift-package-manager/Sourcswift-package-manager/Sources/PackageLoading/ManifestLoader.swiftes/PackageLoading/ManifestLoader.swift

so now it is just encoder.outputFormatting = [.sortedKeys]

just make sure you use your paths and don't forget to commit the change in the locally cloned swift-package-manager

this should get you through the compilation stage. i can confirm that the server runs in vim and vscode fine, but there might be some hidden glitches due to the enum edit. i will investigate it a bit further later on

ha100
  • 1,563
  • 1
  • 21
  • 28