SourceKit-LSP build failure when using a downloaded toolchain vs swift docker image

So I've been able to successfully build sourcekit-lsp using the swiftlang/swift:nightly-main-jammy Docker image, but for some reason when I use a regular Ubuntu image and install from a tarball (curl -sL "https://download.swift.org/development/ubuntu2204-aarch64/swift-DEVELOPMENT-SNAPSHOT-2023-10-22-a/swift-DEVELOPMENT-SNAPSHOT-2023-10-22-a-ubuntu22.04-aarch64.tar.gz" | tar xz --strip-components=1 -C /swift) the build fails with the following error:

/sourcekit-lsp/.build/checkouts/swift-tools-support-core/Sources/TSCBasic/FileSystem.swift:528:24: error: value of optional type 'UnsafeMutablePointer<FILE>?' (aka 'Optional<UnsafeMutablePointer<_IO_FILE>>') must be unwrapped to a value of type 'UnsafeMutablePointer<FILE>' (aka 'UnsafeMutablePointer<_IO_FILE>')
        defer { fclose(fp) }

The main difference I am aware of is that docker image has Swift installed in /usr, whereas I'm extracting the tarball to /swift (this makes some other bits of my config simpler). So in the swift container I'm using swift build -Xcxx -I/usr/lib/swift -Xcxx -I/usr/lib/swift/Block but with the tarball I'm using swift build -Xcxx -I/swift/usr/lib/swift -Xcxx -I/swift/usr/lib/swift/Block (with the correct dependencies and location added as the first entry in PATH as outlined in the docs).

Has anyone ran into a similar issue or have advice on how to fix?

Thanks!

Looks like I had an incompatible C++ standard library in my container... fixed by moving some config around.

1 Like