oraios/serena · error · RuntimeError

nixd failed to run: {result.stderr}

Error message

nixd failed to run: {result.stderr}

What it means

To validate the install, _get_or_install_core_dependency runs `nixd --version` with a 5s timeout and check=False. A non-zero exit code raises RuntimeError including nixd's stderr, meaning the binary exists but failed to execute.

Source

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

            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]:
            """Return the nixd stdio launch command."""
            return [core_path]

    def _extend_nix_symbol_range_to_include_semicolon(
        self, symbol: ls_types.UnifiedSymbolInformation, file_content: str
    ) -> ls_types.UnifiedSymbolInformation:
        """
        Extend symbol range to include trailing semicolon for Nix attribute symbols.

        nixd provides ranges that exclude semicolons (expression-level), but serena needs
        statement-level ranges that include semicolons for proper replacement.
        """

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Run `nixd --version` manually to see the underlying error.
  2. Reinstall nixd: nix profile install github:nix-community/nixd (or brew reinstall nixd).
  3. Remove broken binaries from PATH so the installer produces a fresh nixd.

Example fix

// before
nixd_path = "/opt/broken/nixd"  # exits non-zero
// after
nix profile install github:nix-community/nixd  # then verify: nixd --version
Defensive patterns

Strategy: try-catch

Validate before calling

import subprocess
r = subprocess.run(["nixd", "--version"], capture_output=True, text=True)
assert r.returncode == 0, r.stderr

Try / catch

try:
    server = NixdLanguageServer(...)
except RuntimeError as e:
    if str(e).startswith("nixd failed to run"):
        reinstall_nixd()
    else:
        raise

Prevention

When it happens

Trigger: The resolved nixd path points to a binary that exits non-zero on --version: broken/incompatible build, missing dynamic libraries, wrong-architecture binary, or a shim script that fails.

Common situations: Partially interrupted installation; nixd built for a different platform; sandboxed environments where the nix store binary cannot execute; a corrupted nix profile.

Related errors


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