oraios/serena · error · RuntimeError

nixd (Nix Language Server) is not installed. Please install

Error message

nixd (Nix Language Server) is not installed.
Please install nixd using one of the following methods:
  - Using Nix flakes: nix profile install github:nix-community/nixd
  - From nixpkgs: nix-env -iA nixpkgs.nixd
  - On macOS with Homebrew: brew install nixd

After installation, make sure 'nixd' is in your PATH.

What it means

After confirming Nix exists, _get_or_install_core_dependency tries _get_nixd_path() and then _install_nixd_with_nix(). If both fail to yield a nixd executable, RuntimeError is raised listing all supported installation methods (Nix flake, nixpkgs, Homebrew).

Source

Thrown at src/solidlsp/language_servers/nixd_ls.py:124

                log.error("Nix install timed out after 10 minutes")
            except Exception:
                log.exception("Error installing nixd with nix")

            return None

        def _get_or_install_core_dependency(self) -> str:
            """Return a working nixd path, installing nixd when necessary."""
            if not shutil.which("nix"):
                log.error("Nix is not installed. nixd requires Nix to function properly.")
                raise RuntimeError("Nix is required for nixd. Please install Nix from https://nixos.org/download.html")

            nixd_path = self._get_nixd_path()
            if not nixd_path:
                log.info("nixd not found. Attempting to install...")
                nixd_path = self._install_nixd_with_nix()

            if not nixd_path:
                raise RuntimeError(
                    "nixd (Nix Language Server) is not installed.\n"
                    "Please install nixd using one of the following methods:\n"
                    "  - Using Nix flakes: nix profile install github:nix-community/nixd\n"
                    "  - From nixpkgs: nix-env -iA nixpkgs.nixd\n"
                    "  - On macOS with Homebrew: brew install nixd\n\n"
                    "After installation, make sure 'nixd' is in your PATH."
                )

            try:
                result = subprocess_run([nixd_path, "--version"], capture_output=True, text=True, check=False, timeout=5)
                if result.returncode != 0:
                    raise RuntimeError(f"nixd failed to run: {result.stderr}")
            except Exception as exc:
                raise RuntimeError(f"Failed to verify nixd installation: {exc}") from exc

            return nixd_path

        def _create_launch_command(self, core_path: str) -> list[str]:

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Run: nix profile install github:nix-community/nixd (Nix flakes) or nix-env -iA nixpkgs.nixd.
  2. Or install via Homebrew on macOS: brew install nixd.
  3. Verify `nixd` resolves on PATH with `which nixd`; if installed elsewhere, add its directory to PATH.

Example fix

// before
# nixd not installed
// after
nix profile install github:nix-community/nixd
Defensive patterns

Strategy: validation

Validate before calling

import shutil
if not shutil.which("nixd"):
    raise SystemExit("Install nixd: nix profile install github:nix-community/nixd")

Try / catch

try:
    server = NixdLanguageServer(...)
except RuntimeError as e:
    if "nixd (Nix Language Server) is not installed" in str(e):
        subprocess.run(["nix", "profile", "install", "github:nix-community/nixd"], check=True)
    else:
        raise

Prevention

When it happens

Trigger: Starting the nixd language server when nixd is neither pre-installed nor on PATH, and the automatic install via Nix fails or produces no usable path.

Common situations: Nix present but nixd never installed; the `nix profile install` step fails offline or due to missing flake support in old Nix versions; nixd installed but not on PATH of the process environment.

Related errors


AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29). Data as JSON: /api/errors/793623ecdcb68443. Report an issue: GitHub.