{"record":{"id":"9e4f933944a701a2","repo":"oraios/serena","slug":"failed-to-read-nixd-configuration-file-config-pa","errorCode":null,"errorMessage":"Failed to read nixd configuration file '{config_path}': {exc}","messagePattern":"Failed to read nixd configuration file '(.+?)': (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/solidlsp/language_servers/nixd_ls.py","lineNumber":263,"sourceCode":"        config_path_value = custom_settings.get(\"config_path\")\n        if config_path_value is None:\n            return cls._create_default_nixd_settings()\n        if not isinstance(config_path_value, str) or not config_path_value.strip():\n            raise ValueError(\"ls_specific_settings.nix.config_path must be a non-empty absolute path\")\n\n        config_path = Path(config_path_value).expanduser()\n        if not config_path.is_absolute():\n            raise ValueError(f\"ls_specific_settings.nix.config_path must be absolute: {config_path_value!r}\")\n\n        try:\n            with config_path.open(encoding=\"utf-8\") as config_file:\n                settings = json.load(config_file)\n        except json.JSONDecodeError as exc:\n            raise ValueError(\n                f\"Invalid JSON in nixd configuration file '{config_path}': {exc.msg} (line {exc.lineno}, column {exc.colno})\"\n            ) from exc\n        except OSError as exc:\n            raise RuntimeError(f\"Failed to read nixd configuration file '{config_path}': {exc}\") from exc\n\n        if not isinstance(settings, dict):\n            raise ValueError(\n                f\"Invalid nixd configuration file '{config_path}': expected a JSON object containing the value of the 'nixd' section\"\n            )\n        return settings\n\n    @staticmethod\n    def _resolve_nixd_configuration_section(settings: dict[str, Any], section: object) -> Any:\n        \"\"\"Resolve a ``nixd`` configuration section from the effective settings.\"\"\"\n        if section == \"nixd\":\n            return deepcopy(settings)\n        if not isinstance(section, str) or not section.startswith(\"nixd.\"):\n            return {}\n\n        value: Any = settings\n        for key in section.removeprefix(\"nixd.\").split(\".\"):\n            if not key or not isinstance(value, dict) or key not in value:","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/language_servers/nixd_ls.py#L245-L281","documentation":"This RuntimeError is raised when the nixd language-server configuration file referenced by the 'config_path' setting cannot be opened or read by the OS. The library reads the JSON config at startup (_load_nixd_settings) and wraps any OSError (missing file, permission denied, is-a-directory) into this error with the original OS message included. It is thrown from the nixd language server constructor, so server startup fails.","triggerScenarios":"Calling the nixd language server __init__ with a 'config_path' setting pointing to a file that does not exist, has bad permissions, or is a directory; json.load then raises OSError (e.g. FileNotFoundError, PermissionError, IsADirectoryError) which is re-raised as RuntimeError.","commonSituations":"Typo in the config path in user settings; config file deleted or moved after settings were written; running the server as a different user without read permission; passing a directory path instead of a file path; relative path used while cwd differs from expectation (though validation usually requires absolute).","solutions":["Verify the path in the nixd 'config_path' setting exists and is a regular readable file (ls -l <path>).","Fix the path in settings to the correct absolute path of the nixd JSON config.","Fix file permissions (chmod/chown) so the process user can read the file.","If no custom config is needed, remove 'config_path' so built-in defaults are used."],"exampleFix":"// before\nconfig_path: \"/home/user/.config/nixd/nixd.jscon\"  // typo, file missing\n// after\nconfig_path: \"/home/user/.config/nixd/nixd.json\"","handlingStrategy":"validation","validationCode":"import json, os\n\ndef validate_nixd_config_path(config_path: str) -> None:\n    if not os.path.isabs(config_path):\n        raise ValueError(f\"config_path must be absolute: {config_path}\")\n    if not os.path.isfile(config_path):\n        raise FileNotFoundError(f\"nixd config not a readable file: {config_path}\")\n    if not os.access(config_path, os.R_OK):\n        raise PermissionError(f\"no read permission: {config_path}\")\n    with open(config_path, \"r\", encoding=\"utf-8\") as f:\n        json.load(f)  # also pre-checks JSON validity","typeGuard":null,"tryCatchPattern":"try:\n    server = NixdLanguageServer(config_path=cfg[\"nixd\"][\"config_path\"], **common)\nexcept RuntimeError as e:\n    if \"Failed to read nixd configuration file\" in str(e):\n        logger.error(\"Falling back to default nixd settings: %s\", e)\n        server = NixdLanguageServer(**common)  # omit config_path\n    else:\n        raise","preventionTips":["Keep the nixd config path in one constant/setting and verify it once at app startup.","Always store absolute paths; never rely on the process cwd.","Add the config file to deployment/packaging so it ships with the environment.","Check os.access(path, os.R_OK) after permission changes or user switches."],"tags":["nixd","config-file","runtime-error","file-io"],"backgroundTag":"config-file-not-readable","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}