{"record":{"id":"afe8e154ff5e1050","repo":"pola-rs/polars","slug":"invalid-config-file-did-you-mean-to-use-load-n-err","errorCode":null,"errorMessage":"invalid Config file (did you mean to use `load`?)\\n{err}","messagePattern":"invalid Config file \\(did you mean to use `load`\\?\\)\\\\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/config.py","lineNumber":447,"sourceCode":"    def load_from_file(cls, file: Path | str) -> Config:\n        \"\"\"\n        Load (and set) previously saved Config options from file.\n\n        Parameters\n        ----------\n        file : Path | str\n            File path to a JSON string produced by `Config.save()`.\n\n        See Also\n        --------\n        load : Load (and set) Config options from a JSON string.\n        save : Save the current set of Config options as a JSON string or file.\n        \"\"\"\n        try:\n            options = Path(normalize_filepath(file)).read_text()\n        except OSError as err:\n            msg = f\"invalid Config file (did you mean to use `load`?)\\n{err}\"\n            raise ValueError(msg) from err\n\n        return cls.load(options)\n\n    @classmethod\n    def restore_defaults(cls) -> type[Config]:\n        \"\"\"\n        Reset all polars Config settings to their default state.\n\n        Notes\n        -----\n        This method operates by removing all Config options from the environment,\n        and then setting any local (non-env) options back to their default value.\n\n        Examples\n        --------\n        >>> cfg = pl.Config.restore_defaults()  # doctest: +SKIP\n        \"\"\"\n        # unset all Config environment variables","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/config.py#L429-L465","documentation":"Raised by Config.load_from_file when the file path cannot be read (OSError), e.g. the file does not exist. The message hints that if you intended to parse a JSON string you should use Config.load instead.","triggerScenarios":"Config.load_from_file('missing.json') with a nonexistent/unreadable path, or passing a JSON string to load_from_file instead of load.","commonSituations":"Wrong path or typo'd filename; confusing load/load_from_file; permission issues on the config file.","solutions":["Verify the file exists at the given path (os.path.exists)","Switch to Config.load(json_string) if you already have the string","Normalize/expand the path (the API applies normalize_filepath; use absolute paths)","Check read permissions on the config file"],"exampleFix":"// before\npl.Config.load_from_file(json_string)  # ValueError: invalid Config file\n// after\npl.Config.load(json_string)","handlingStrategy":"try-catch","validationCode":"from pathlib import Path\np = Path(path).expanduser()\nif not p.is_file():\n    raise FileNotFoundError(path)","typeGuard":"def config_file_ok(path: str) -> bool:\n    return Path(path).expanduser().is_file()","tryCatchPattern":"try:\n    pl.Config.load_from_file(path)\nexcept ValueError as e:\n    logging.error('cannot read config file: %s', e)\n    raise","preventionTips":["Check file existence before load_from_file","Use absolute, expanded paths","Do not swap load/load_from_file"],"tags":["polars","config","file"],"backgroundTag":"config-file-not-found","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}