Skip to content

Instantly share code, notes, and snippets.

@TyrfingMjolnir
Last active November 29, 2024 22:11
Show Gist options
  • Save TyrfingMjolnir/ad7bbc1940f1dcf218204b3149d488ed to your computer and use it in GitHub Desktop.
Save TyrfingMjolnir/ad7bbc1940f1dcf218204b3149d488ed to your computer and use it in GitHub Desktop.
Install sourcekit-lsp under ubuntu 22.04

Here is the version of Ubuntu in question: https://releases.ubuntu.com/jammy/ubuntu-22.04.5-live-server-amd64.iso

$ sudo apt remove cloud-init
$ sudo apt-get install curl clang libicu-dev git libatomic1  libxml2 libcurl4 zlib1g-dev libbsd0 tzdata libssl-dev libsqlite3-dev libblocksruntime-dev libncurses5-dev libdispatch-dev libicu70 libicu-dev git
$ curl -L https://swiftlang.github.io/swiftly/swiftly-install.sh | bash
$ . $HOME/.local/share/swiftly/env.sh
$ swiftly install latest
$ swiftly use latest

The following has already been installed by the toolchain.

$ mkdir source
$ cd source/
$ git clone https://github.com/apple/sourcekit-lsp
$ cd sourcekit-lsp/
$ swift package update
$ swift build -Xcxx -I/home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift
$ sudo mv .build/x86_64-unknown-linux-gnu/debug/sourcekit-lsp /usr/local/bin
$ sourcekit-lsp --help
OVERVIEW: Language Server Protocol implementation for Swift and C-based languages

USAGE: sourcekit-lsp <options> <subcommand>

OPTIONS:
  --configuration <configuration>
                          Build with configuration [debug|release] (default: debug)
  --scratch-path, --build-path <scratch-path>
                          Specify build/cache directory (--build-path option is deprecated, --scratch-path should be used instead)
  -Xcc <Xcc>              Pass flag through to all C compiler invocations
  -Xcxx <Xcxx>            Pass flag through to all C++ compiler invocations
  -Xlinker <Xlinker>      Pass flag through to all linker invocations
  -Xswiftc <Xswiftc>      Pass flag through to all Swift compiler invocations
  -Xclangd <Xclangd>      Pass options to clangd command-line
  -index-store-path <index-store-path>
                          Override index-store-path from the build system
  -index-db-path <index-db-path>
                          Override index-database-path from the build system
  -index-prefix-map <index-prefix-map>
                          Override the prefix map from the build system, values of form 'remote=local'
  --default-workspace-type <default-workspace-type>
                          Override default workspace type selection; one of 'swiftPM', 'compilationDatabase', or 'buildServer'
  --compilation-db-search-path <compilation-db-search-path>
                          Specify a relative path where sourcekit-lsp should search for `compile_commands.json` or `compile_flags.txt` relative to the root of a workspace. Multiple search paths may be specified by repeating this option.
  --generated-files-path <generated-files-path>
                          Specify the directory where generated files will be stored (default: /tmp/sourcekit-lsp)
  --experimental-feature <experimental-feature>
                          Enable an experimental sourcekit-lsp feature.
                          Available features are: dummy
  -h, --help              Show help information.

SUBCOMMANDS:
  diagnose                Creates a bundle containing information that help diagnose issues with sourcekit-lsp
  debug                   Commands to debug sourcekit-lsp. Intended for developers of sourcekit-lsp

  See 'sourcekit-lsp help <subcommand>' for detailed help.

Not sure which distros will be able to run this binary; here is the ldd output for the binary:

$ ldd /usr/local/bin/sourcekit-lsp
        linux-vdso.so.1 (0x00007ffc79df8000)
        libFoundationInternationalization.so => /home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux/libFoundationInternationalization.so (0x00007f64f7d53000)
        libFoundationEssentials.so => /home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux/libFoundationEssentials.so (0x00007f64f77f3000)
        libsqlite3.so.0 => /lib/x86_64-linux-gnu/libsqlite3.so.0 (0x00007f64f76a1000)
        libswiftRegexBuilder.so => /home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux/libswiftRegexBuilder.so (0x00007f64f768a000)
        libswiftSwiftOnoneSupport.so => /home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux/libswiftSwiftOnoneSupport.so (0x00007f64f7647000)
        libswiftCore.so => /home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux/libswiftCore.so (0x00007f64f6f7d000)
        libswift_Concurrency.so => /home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux/libswift_Concurrency.so (0x00007f64f6ee6000)
        libswift_StringProcessing.so => /home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux/libswift_StringProcessing.so (0x00007f64f6e0b000)
        libswift_RegexParser.so => /home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux/libswift_RegexParser.so (0x00007f64f6cf7000)
        libswiftGlibc.so => /home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux/libswiftGlibc.so (0x00007f64f6ce4000)
        libBlocksRuntime.so => /home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux/libBlocksRuntime.so (0x00007f64f6cdd000)
        libdispatch.so => /home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux/libdispatch.so (0x00007f64f6c7d000)
        libswiftDispatch.so => /home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux/libswiftDispatch.so (0x00007f64f6c4c000)
        libFoundation.so => /home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux/libFoundation.so (0x00007f64f6647000)
        libFoundationNetworking.so => /home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux/libFoundationNetworking.so (0x00007f64f6531000)
        libFoundationXML.so => /home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux/libFoundationXML.so (0x00007f64f64e6000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f64f63ff000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f64f61d3000)
        libncurses.so.6 => /lib/x86_64-linux-gnu/libncurses.so.6 (0x00007f64f61ab000)
        libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f64f6179000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f64f6159000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f64f5f2e000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f64fe831000)
        lib_FoundationICU.so => /home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux/lib_FoundationICU.so (0x00007f64f3a95000)
        libswiftSynchronization.so => /home/user/.local/share/swiftly/toolchains/6.0.2/usr/lib/swift/linux/libswiftSynchronization.so (0x00007f64f3a84000)
        libcurl.so.4 => /lib/x86_64-linux-gnu/libcurl.so.4 (0x00007f64f39dd000)
        libxml2.so.2 => /lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f64f37f9000)
        libnghttp2.so.14 => /lib/x86_64-linux-gnu/libnghttp2.so.14 (0x00007f64f37cf000)
        libidn2.so.0 => /lib/x86_64-linux-gnu/libidn2.so.0 (0x00007f64f37ae000)
        librtmp.so.1 => /lib/x86_64-linux-gnu/librtmp.so.1 (0x00007f64f378f000)
        libssh.so.4 => /lib/x86_64-linux-gnu/libssh.so.4 (0x00007f64f3722000)
        libpsl.so.5 => /lib/x86_64-linux-gnu/libpsl.so.5 (0x00007f64f370c000)
        libssl.so.3 => /lib/x86_64-linux-gnu/libssl.so.3 (0x00007f64f3668000)
        libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3 (0x00007f64f3224000)
        libgssapi_krb5.so.2 => /lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007f64f31d0000)
        libldap-2.5.so.0 => /lib/x86_64-linux-gnu/libldap-2.5.so.0 (0x00007f64f3171000)
        liblber-2.5.so.0 => /lib/x86_64-linux-gnu/liblber-2.5.so.0 (0x00007f64f3160000)
        libzstd.so.1 => /lib/x86_64-linux-gnu/libzstd.so.1 (0x00007f64f308f000)
        libbrotlidec.so.1 => /lib/x86_64-linux-gnu/libbrotlidec.so.1 (0x00007f64f3081000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f64f3065000)
        libicuuc.so.70 => /lib/x86_64-linux-gnu/libicuuc.so.70 (0x00007f64f2e6a000)
        liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f64f2e3f000)
        libunistring.so.2 => /lib/x86_64-linux-gnu/libunistring.so.2 (0x00007f64f2c93000)
        libgnutls.so.30 => /lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007f64f2aa8000)
        libhogweed.so.6 => /lib/x86_64-linux-gnu/libhogweed.so.6 (0x00007f64f2a60000)
        libnettle.so.8 => /lib/x86_64-linux-gnu/libnettle.so.8 (0x00007f64f2a1a000)
        libgmp.so.10 => /lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f64f2998000)
        libkrb5.so.3 => /lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007f64f28cd000)
        libk5crypto.so.3 => /lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007f64f289c000)
        libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f64f2896000)
        libkrb5support.so.0 => /lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007f64f2888000)
        libsasl2.so.2 => /lib/x86_64-linux-gnu/libsasl2.so.2 (0x00007f64f286d000)
        libbrotlicommon.so.1 => /lib/x86_64-linux-gnu/libbrotlicommon.so.1 (0x00007f64f284a000)
        libicudata.so.70 => /lib/x86_64-linux-gnu/libicudata.so.70 (0x00007f64f0c2a000)
        libp11-kit.so.0 => /lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f64f0aef000)
        libtasn1.so.6 => /lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007f64f0ad7000)
        libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f64f0ad0000)
        libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f64f0abc000)
        libffi.so.8 => /lib/x86_64-linux-gnu/libffi.so.8 (0x00007f64f0aaf000)

Optional fun stuff: Vapor

$ cd ~/source
$ git clone https://github.com/vapor/toolbox.git
$ git checkout 18.7.5
$ make install
$ vapor --help
Usage: vapor <command>

Vapor Toolbox (Server-side Swift web framework)

Commands:
       build Builds an app in the console.
       clean Cleans temporary files.
      heroku Commands for working with Heroku.
         new Generates a new app.
         run Runs an app from the console.
             Equivalent to `swift run App`.
             The --enable-test-discovery flag is automatically set if needed.
  supervisor Commands for working with supervisord.
       xcode Opens an app in Xcode.

Use `vapor <command> [--help,-h]` for more information on a command.
Name Path
sourcekit-lsp.serverPath /usr/share/swift/usr/bin/sourcekit-lsp
lldb.library /usr/share/swift/usr/lib/liblldb.so
swiftformat.path /usr/local/bin/swiftformat
swiftlint.path /usr/local/bin/swiftlint
swiftlint.toolchainPath /usr/share/swift/usr/bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment