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

Zed Editor package can't use language servers #309662

Open
ImTheSquid opened this issue May 6, 2024 · 7 comments
Open

Zed Editor package can't use language servers #309662

ImTheSquid opened this issue May 6, 2024 · 7 comments

Comments

@ImTheSquid
Copy link

Describe the bug

Zed has the same issue as many other editors where it tries to run dynamically-linked libraries. A FHS chroot like vscode-fhs would probably fix this.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Open Zed
  2. Attempt to use any language server

Expected behavior

Zed is able to download and execute the language server of choice.

Additional context

Here is the log entry:

2024-05-06T18:29:14-04:00 [INFO] starting language server. binary path: "/home/jack/.local/share/zed/languages/rust-analyzer/rust-analyzer-2024-05-06", working directory: "/home/jack/Code/Rust/CodeCheck", args: []
2024-05-06T18:29:14-04:00 [ERROR] crates/lsp/src/lsp.rs:352: cannot read LSP message headers
2024-05-06T18:29:14-04:00 [ERROR] failed to start language server "rust-analyzer": server shut down
2024-05-06T18:29:14-04:00 [ERROR] server stderr: Some("Could not start dynamically linked executable: /home/jack/.local/share/zed/languages/rust-analyzer/rust-analyzer-2024-05-06\nNixOS cannot run dynamically linked executables intended for generic\nlinux environments out of the box. For more information, see:\n")

Notify maintainers

@GaetanLepage
@niklaskorz

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.6.30, NixOS, 24.05 (Uakari), 24.05pre621993.25865a40d14b`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.2`
 - channels(root): `"nixos"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Add a 👍 reaction to issues you find important.

@FireFragment
Copy link

Temporary workaround that works for me with Rust Analyzer is to use buildFHSEnv.

Create shell.nix and paste:

{ pkgs ? import <nixpkgs> {} }:

(pkgs.buildFHSEnv {
    name = "zed";
    runScript = "zed";
}).env

Then run nix-shell in the same directory.

@GaetanLepage
Copy link
Contributor

Is zed trying to run the language servers from your PATH, failing and then defaulting to its own binaries (~/.local/share/zed/languages) or is it directly using those regardless of your environment ?

@ImTheSquid
Copy link
Author

As far as I can tell I think it only tries from the ones it downloads.

2024-05-12T08:35:16-04:00 [INFO] starting language servers for Rust: rust-analyzer
2024-05-12T08:35:16-04:00 [INFO] starting language server "rust-analyzer", path: "/home/jack/Code/Rust/CodeCheck", id: 1
2024-05-12T08:35:16-04:00 [INFO] starting language servers for Rust: rust-analyzer
2024-05-12T08:35:16-04:00 [INFO] starting language servers for Nix: 
2024-05-12T08:35:16-04:00 [INFO] starting language servers for Git Ignore: 
2024-05-12T08:35:16-04:00 [INFO] starting language servers for Rust: rust-analyzer
2024-05-12T08:35:16-04:00 [INFO] starting language servers for Rust: rust-analyzer
2024-05-12T08:35:16-04:00 [INFO] fetching latest version of language server "rust-analyzer"
2024-05-12T08:35:16-04:00 [INFO] Creating buffer 0x56126b48f6c0 of size 45472, name 'chunk-6', handle 8
2024-05-12T08:35:17-04:00 [INFO] add connection to peer
2024-05-12T08:35:17-04:00 [INFO] add_connection;
2024-05-12T08:35:17-04:00 [INFO] waiting for server hello
2024-05-12T08:35:17-04:00 [INFO] got server hello
2024-05-12T08:35:17-04:00 [INFO] set status to connected (connection id: ConnectionId { owner_id: 0, id: 0 }, peer id: PeerId { owner_id: 403, id: 1518134 })
2024-05-12T08:35:17-04:00 [INFO] set status on client 55287: Connected { peer_id: PeerId { owner_id: 403, id: 1518134 }, connection_id: ConnectionId { owner_id: 0, id: 0 } }
2024-05-12T08:35:17-04:00 [INFO] downloading language server "rust-analyzer"
2024-05-12T08:35:18-04:00 [INFO] Creating texture 0x56126b48fc50 of size 1024x1024x1 and format Bgra8Unorm, name 'atlas', handle 9
2024-05-12T08:35:18-04:00 [WARN] GPU frame is out of date
2024-05-12T08:35:18-04:00 [INFO] Using surface present mode FIFO_RELAXED
2024-05-12T08:35:20-04:00 [INFO] starting language server. binary path: "/home/jack/.local/share/zed/languages/rust-analyzer/rust-analyzer-2024-05-06", working directory: "/home/jack/Code/Rust/CodeCheck", args: []
2024-05-12T08:35:20-04:00 [ERROR] crates/lsp/src/lsp.rs:352: cannot read LSP message headers
2024-05-12T08:35:20-04:00 [ERROR] crates/lsp/src/lsp.rs:374: Broken pipe (os error 32)
2024-05-12T08:35:20-04:00 [ERROR] failed to start language server "rust-analyzer": server shut down
2024-05-12T08:35:20-04:00 [ERROR] server stderr: Some("Could not start dynamically linked executable: /home/jack/.local/share/zed/languages/rust-analyzer/rust-analyzer-2024-05-06\nNixOS cannot run dynamically linked executables intended for generic\nlinux environments out of the box. For more information, see:\n")

@GaetanLepage
Copy link
Contributor

According to their website, Zed is not yet able to connect with "arbitrary language servers". Maybe we'll have to wait for this to be able to inject our nix built binaries...

@Liamolucko
Copy link
Contributor

Liamolucko commented May 29, 2024

According to their website, Zed is not yet able to connect with "arbitrary language servers". Maybe we'll have to wait for this to be able to inject our nix built binaries...

There seems to be an (undocumented) configuration option to override the language server binary it uses for a language: #284064 (comment).

EDIT: seems like it only works for C, Tailwind, Rust and Go right now though, since each language has to set it up manually.

@oliveirarleo
Copy link

oliveirarleo commented May 31, 2024

Try this:
In my configuration.nix:

 with pkgs; [
  unstable-small.zed-editor
  nodePackages.typescript-language-server
  tree-sitter-grammars.tree-sitter-javascript
  elixir-ls
  tree-sitter-grammars.tree-sitter-elixir
 ...
]

Run with:

steam-run zed &

I got it working by running with steam-run, since the default download fails and binaries for the lsp are not patched. The editor uses the system's lsp in case it cannot download.

I've noticed this by investigating zed logs and seeing logs of the downloaded node command was not patched. Seems like there is more to it, since elixir was not working without steam run as well.
image

@vinicius507
Copy link

vinicius507 commented Jun 7, 2024

I'm executing Zed in a FHS environment using:

{pkgs, ...}: let
  zed-fhs = pkgs.buildFHSUserEnv {
    name = "zed";
    targetPkgs = pkgs:
      with pkgs; [
        zed-editor
      ];
    runScript = "zed";
  };
in {
  home.packages = [zed-fhs];
};

And it works quite well. The only problem is that it does not show up in the desktop entries.

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

No branches or pull requests

6 participants