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

sourcekit-lsp crashes when opening .swift files in VSCode #331943

Open
thomaseizinger opened this issue Aug 3, 2024 · 1 comment
Open

sourcekit-lsp crashes when opening .swift files in VSCode #331943

thomaseizinger opened this issue Aug 3, 2024 · 1 comment
Labels

Comments

@thomaseizinger
Copy link
Contributor

thomaseizinger commented Aug 3, 2024

Describe the bug

sourcekit-lsp crashes when opening .swift files with:

2024-08-03 18:01:29.517 sourcekit-lsp[56787:c4a006c0] failed to start language service open("/nix/store/h8gh9cg2z137ql7h1bgnhr9ixwcwj4az-swift-5.8/lib/libsourcekitdInProc.so: undefined symbol: _Z13OStream_write14BridgedOStreamN4llvm9StringRefE")

Steps To Reproduce

  1. Configure VSCode-swift with:
userSettings = {
	"swift.path" = "${pkgs.swiftPackages.swift-unwrapped}/bin";
	"swift.sourcekit-lsp.serverPath" = "${pkgs.sourcekit-lsp}/bin/sourcekit-lsp";
];
  1. Open a .swift file in an editor

Expected behavior

Auto-complete and code analysis from the language server.

Additional context

A related bug is open on the Swift repository: swiftlang/swift#67975

It hints that there might be a problem in how sourcekit-lsp gets built so I am opening this here. The suggestion there is that sourcekit-lsp should statically link against the above symbol.

The original issue I opened was: swiftlang/vscode-swift#988. There the vscode-swift people are wondering why sourcekit-lsp is in a different package to begin with.

Notify maintainers

@dtzWill @trepetti @dduan @Trundle @stephank

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.8.12, NixOS, 24.11 (Vicuna), 24.11.20240620.d603719`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.2`
 - channels(root): `"home-manager-23.11.tar.gz, nixos-23.11, nixos-hardware"`
 - nixpkgs: `/nix/store/xfpiyfgf6y30fxk5ngv0cjn474qfr3sj-source`

Add a 👍 reaction to issues you find important.

@nadevko
Copy link

nadevko commented Oct 7, 2024

Same error.

Aug 3

Do you find any way to fix it?

shell.nix of project

{
  pkgs ? import <nixpkgs> { },
}:
with pkgs;
mkShell.override { inherit (swiftPackages) stdenv; } rec {
  vscode-settings = writeText "settings.json" (
    builtins.toJSON {
      "swift.path" = "${swiftPackages.swift-unwrapped}/bin";
      "swift.sourcekit-lsp.serverPath" = "${sourcekit-lsp}/bin/sourcekit-lsp";
      "lldb.library" = "${swiftPackages.swift-unwrapped}/lib/liblldb.so";
      "lldb.launch.expressions" = "native";
    }
  );

  packages = [
    swift
    swiftpm
    swift-corelibs-libdispatch
    swiftPackages.Foundation
    swiftPackages.Dispatch
  ];

  shellHook = ''
    LD_LIBRARY_PATH+=":${swift-corelibs-libdispatch}/lib";
    mkdir .vscode &>/dev/null
    cp --force ${vscode-settings} .vscode/settings.json
  '';
}

SourceKit Language Server logs from sswg.swift-lang VSCode extension (I use Codium)

2024-10-07 12:51:30.019 sourcekit-lsp[9338:3e0006c0] Could not determine host OS. Falling back to using '.so' as dynamic library extension
2024-10-07 12:51:30.019 sourcekit-lsp[9338:3e0006c0] Could not determine host OS. Falling back to using '.so' as dynamic library extension
2024-10-07 12:51:30.019 sourcekit-lsp[9338:3e0006c0] Could not determine host OS. Falling back to using '.so' as dynamic library extension
2024-10-07 12:51:30.020 sourcekit-lsp[9338:3e0006c0] Could not determine host OS. Falling back to using '.so' as dynamic library extension
2024-10-07 12:51:30.020 sourcekit-lsp[9338:3e0006c0] Could not determine host OS. Falling back to using '.so' as dynamic library extension
2024-10-07 12:51:30.020 sourcekit-lsp[9338:3e0006c0] Could not determine host OS. Falling back to using '.so' as dynamic library extension
2024-10-07 12:51:30.020 sourcekit-lsp[9338:3e0006c0] Could not determine host OS. Falling back to using '.so' as dynamic library extension
2024-10-07 12:51:30.020 sourcekit-lsp[9338:3e0006c0] Could not determine host OS. Falling back to using '.so' as dynamic library extension
2024-10-07 12:51:30.020 sourcekit-lsp[9338:3e0006c0] Could not determine host OS. Falling back to using '.so' as dynamic library extension
2024-10-07 12:51:30.020 sourcekit-lsp[9338:3e0006c0] Could not determine host OS. Falling back to using '.so' as dynamic library extension
2024-10-07 12:51:30.020 sourcekit-lsp[9338:3e0006c0] Could not determine host OS. Falling back to using '.so' as dynamic library extension
2024-10-07 12:51:30.020 sourcekit-lsp[9338:3e0006c0] Could not determine host OS. Falling back to using '.so' as dynamic library extension
2024-10-07 12:51:30.021 sourcekit-lsp[9338:3e0006c0] Could not determine host OS. Falling back to using '.so' as dynamic library extension
2024-10-07 12:51:30.021 sourcekit-lsp[9338:3e0006c0] Could not determine host OS. Falling back to using '.so' as dynamic library extension
2024-10-07 12:51:30.193 sourcekit-lsp[9338:3e0006c0] [error]: Invalid manifest (compiled with: ["/nix/store/rh4jimyaclrhh04j0656a8gkxqsgk2k1-swift-5.8/bin/swiftc", "-vfsoverlay", "/tmp/TemporaryDirectory.SLww15/vfs.yaml", "-L", "/nix/store/rh4jimyaclrhh04j0656a8gkxqsgk2k1-swift-5.8/lib/swift/pm/ManifestAPI", "-lPackageDescription", "-Xlinker", "-rpath", "-Xlinker", "/nix/store/rh4jimyaclrhh04j0656a8gkxqsgk2k1-swift-5.8/lib/swift/pm/ManifestAPI", "-swift-version", "5", "-I", "/nix/store/rh4jimyaclrhh04j0656a8gkxqsgk2k1-swift-5.8/lib/swift/pm/ManifestAPI", "-package-description-version", "5.8.0", "/home/nadevko/example/Package.swift", "-o", "/tmp/TemporaryDirectory.uYSWUf/example-manifest"])
<unknown>:0: warning: glibc not found for 'x86_64-pc-linux-gnu'; C stdlib may be unavailable
<unknown>:0: error: could not find module '_Concurrency' for target 'x86_64-pc-linux-gnu'; found: x86_64-unknown-linux-gnu, at: /nix/store/szbmx8gzg6fi977jbr5v3lg12b4j2x4v-swift-5.8-lib/lib/swift/linux/_Concurrency.swiftmodule
2024-10-07 12:51:30.194 sourcekit-lsp[9338:3e0006c0] failed to create SwiftPMWorkspace at /home/nadevko/example: the package does not contain a buildable target
2024-10-07 12:51:49.904 sourcekit-lsp[9338:360006c0] failed to start language service open("/nix/store/rh4jimyaclrhh04j0656a8gkxqsgk2k1-swift-5.8/lib/libsourcekitdInProc.so: undefined symbol: _Z13OStream_write14BridgedOStreamN4llvm9StringRefE")
[Info  - 12:59:32 PM] Connection to server got closed. Server will restart.
true
[Error - 12:59:32 PM] Server process exited with signal SIGILL.

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

No branches or pull requests

3 participants