Open ImTheSquid opened 1 month ago
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.
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 ?
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")
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...
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: https://github.com/NixOS/nixpkgs/issues/284064#issuecomment-2106030589.
EDIT: seems like it only works for C, Tailwind, Rust and Go right now though, since each language has to set it up manually.
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.
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.
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:
Expected behavior
Zed is able to download and execute the language server of choice.
Additional context
Here is the log entry:
Notify maintainers
@GaetanLepage @niklaskorz
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.Add a :+1: reaction to issues you find important.