oraios/serena · error · ValueError

ls_specific_settings.nix.config_path must be a non-empty abs

Error message

ls_specific_settings.nix.config_path must be a non-empty absolute path

What it means

_load_nixd_settings validates the optional config_path key in ls_specific_settings.nix. If present it must be a non-empty string; an empty, whitespace-only, or non-string value raises ValueError since nixd cannot start without valid settings.

Source

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

                    "installable": "",
                },
            },
        }

    @classmethod
    def _load_nixd_settings(cls, custom_settings: SolidLSPSettings.CustomLSSettings) -> dict[str, Any]:
        """Load nixd settings from ``config_path`` or return the built-in defaults.

        :param custom_settings: Nix-specific language-server settings.
        :return: The value of the nixd configuration section.
        :raises ValueError: If ``config_path`` or its JSON document has an invalid shape.
        :raises RuntimeError: If the configuration file cannot be read.
        """
        config_path_value = custom_settings.get("config_path")
        if config_path_value is None:
            return cls._create_default_nixd_settings()
        if not isinstance(config_path_value, str) or not config_path_value.strip():
            raise ValueError("ls_specific_settings.nix.config_path must be a non-empty absolute path")

        config_path = Path(config_path_value).expanduser()
        if not config_path.is_absolute():
            raise ValueError(f"ls_specific_settings.nix.config_path must be absolute: {config_path_value!r}")

        try:
            with config_path.open(encoding="utf-8") as config_file:
                settings = json.load(config_file)
        except json.JSONDecodeError as exc:
            raise ValueError(
                f"Invalid JSON in nixd configuration file '{config_path}': {exc.msg} (line {exc.lineno}, column {exc.colno})"
            ) from exc
        except OSError as exc:
            raise RuntimeError(f"Failed to read nixd configuration file '{config_path}': {exc}") from exc

        if not isinstance(settings, dict):
            raise ValueError(
                f"Invalid nixd configuration file '{config_path}': expected a JSON object containing the value of the 'nixd' section"

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Set config_path to a non-empty absolute path to your nixd JSON settings file.
  2. Remove the config_path key entirely to use default nixd settings.
  3. Quote/escape values in your config so templating does not collapse them to an empty string.

Example fix

// before
ls_specific_settings.nix.config_path = ""
// after
ls_specific_settings.nix.config_path = "/home/user/.config/nixd/nixd.json"
Defensive patterns

Strategy: validation

Validate before calling

cp = settings.get("ls_specific_settings", {}).get("nix", {}).get("config_path")
if cp is not None and (not isinstance(cp, str) or not cp.strip()):
    raise ValueError("config_path must be a non-empty string or omitted entirely")

Type guard

def is_valid_config_path(v) -> bool:
    return v is None or (isinstance(v, str) and bool(v.strip()))

Try / catch

try:
    server = NixdLanguageServer(...)
except ValueError as e:
    if "must be a non-empty absolute path" in str(e):
        del settings["ls_specific_settings"]["nix"]["config_path"]  # fall back to defaults
    else:
        raise

Prevention

When it happens

Trigger: Setting ls_specific_settings.nix.config_path to "", " ", null-adjacent values, or a non-string (e.g. a number/list) and constructing the nixd language server.

Common situations: YAML/JSON config where an empty string placeholder was left in; templating that substitutes a blank value; users confusing null (which yields defaults) with "" (which is invalid).

Understand the failure class

Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.

Related errors


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