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

[BUG] failed to load zls activated in nix-shell #3063

Open
1 task done
pseudocc opened this issue Mar 11, 2025 · 1 comment · May be fixed by #3064
Open
1 task done

[BUG] failed to load zls activated in nix-shell #3063

pseudocc opened this issue Mar 11, 2025 · 1 comment · May be fixed by #3064
Labels
bug Something isn't working

Comments

@pseudocc
Copy link

Field Description
Plugin lsp
Nixpkgs 24.11
Home Manager 24.11
Project Flake master
  • I have read the FAQ and my bug is not listed there.

Description

I use zig and zls (0.13.0) on my system, but for some reason I have projects developed in zig (0.14.0) which is managed in flake.nix, but zls (0.13.0) is always loaded instead of zls (0.14.0).

Minimal, Reproducible Example (MRE)

programs.nixvim = {
  enable = true;
  plugins.lsp = {
    enable = true;
    servers.zls.enable = true;
  };
}

project flake.nix

{
  description = "MRE";

  # zig 0.14.0
  inputs.nixpkgs.url = "github:nixos/nixpkgs";

  outputs = { self, nixpkgs, ... } @ inputs: let
    inherit (nixpkgs) lib;
    eachSystem = fn:
      lib.foldl' (
        acc: system:
          lib.recursiveUpdate
          acc
          (lib.mapAttrs (_: value: {${system} = value;}) (fn system))
      ) {}
      lib.platforms.unix;
  in
    eachSystem (
      system: let
        pkgs = import nixpkgs {inherit system;};
        zig = pkgs.zig_0_14;
      in {
        devShells.default = pkgs.mkShell {
          buildInputs = [ zig pkgs.zls ];
        };
      }
    );
}

project flake.lock

{
  "nodes": {
    "nixpkgs": {
      "locked": {
        "lastModified": 1741673466,
        "narHash": "sha256-VVXaC6uiwDMabeJE0iz3PmPj6UPrUa2naPT3Yi6ucpA=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "8bf6db44e9869a9bc97fb1a7ffb861a15882eae4",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "nixpkgs": "nixpkgs"
      }
    }
  },
  "root": "root",
  "version": 7
}

Additional Informations

zls-0.13.0 comes first, echo $PATH in neovim:

/nix/store/4zl0m2kisdpy5padk4i8wn6wf041dj5m-zls-0.13.0/bin
...
/nix/store/dh51hvagkd76nlixh4y79k8hl273847w-zig-0.14.0/bin
/nix/store/nn1v1aqacd09i9fzbirqzsy4sh0vnyqv-zls-0.14.0/bin
...
@pseudocc pseudocc added the bug Something isn't working label Mar 11, 2025
@pseudocc
Copy link
Author

Probly related to this "--prefix" line

      extraWrapperArgs = builtins.concatStringsSep " " (
        (optional (
          config.extraPackages != [ ]
        ) ''--prefix PATH : "${lib.makeBinPath config.extraPackages}"'')
        ++ (optional config.wrapRc ''--add-flags -u --add-flags "${initFile}"'')
      );

pseudocc added a commit to pseudocc/nixvim that referenced this issue Mar 11, 2025
@pseudocc pseudocc linked a pull request Mar 11, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant