{"record":{"id":"20e18d8a187a09cf","repo":"hiyouga/LlamaFactory","slug":"file-local-path-not-found","errorCode":null,"errorMessage":"File {local_path} not found.","messagePattern":"File (.+?) not found\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/data/loader.py","lineNumber":82,"sourceCode":"\n    elif dataset_attr.load_from == \"script\":\n        data_path = os.path.join(data_args.dataset_dir, dataset_attr.dataset_name)\n        data_name = dataset_attr.subset\n        data_dir = dataset_attr.folder\n\n    elif dataset_attr.load_from == \"cloud_file\":\n        data_path = dataset_attr.dataset_name\n\n    elif dataset_attr.load_from == \"file\":\n        data_files = []\n        local_path = os.path.join(data_args.dataset_dir, dataset_attr.dataset_name)\n        if os.path.isdir(local_path):  # is directory\n            for file_name in os.listdir(local_path):\n                data_files.append(os.path.join(local_path, file_name))\n        elif os.path.isfile(local_path):  # is file\n            data_files.append(local_path)\n        else:\n            raise ValueError(f\"File {local_path} not found.\")\n\n        data_path = FILEEXT2TYPE.get(os.path.splitext(data_files[0])[-1][1:], None)\n        if data_path is None:\n            raise ValueError(\"Allowed file types: {}.\".format(\",\".join(FILEEXT2TYPE.keys())))\n\n        if any(data_path != FILEEXT2TYPE.get(os.path.splitext(data_file)[-1][1:], None) for data_file in data_files):\n            raise ValueError(\"File types should be identical.\")\n    else:\n        raise NotImplementedError(f\"Unknown load type: {dataset_attr.load_from}.\")\n\n    if dataset_attr.load_from == \"ms_hub\":\n        check_version(\"modelscope>=1.14.0\", mandatory=True)\n        from modelscope import MsDataset  # type: ignore\n        from modelscope.utils.config_ds import MS_DATASETS_CACHE  # type: ignore\n\n        cache_dir = model_args.cache_dir or MS_DATASETS_CACHE\n        dataset = MsDataset.load(\n            dataset_name=data_path,","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/data/loader.py#L64-L100","documentation":"Raised in _load_single_dataset when a dataset entry in dataset_info.json is configured with \"file\" loading but neither a file nor a directory of that name exists under data_args.dataset_dir. The path is resolved as os.path.join(dataset_dir, dataset_name); a miss yields this ValueError before any loading is attempted.","triggerScenarios":"dataset_info.json declares {\"file\": ...} (or the dataset name resolves to load_from == \"file\") and the referenced file/directory does not exist relative to the dataset_dir (default 'data/'). Common with relative paths, wrong working directory, or a typo in the file name.","commonSituations":"Running llamafactory-cli train from a different cwd so the relative data/ dir resolves elsewhere; custom dataset_dir not passed; file placed in another folder; case-sensitivity mismatches on Linux; file left out of a container or cloned repo.","solutions":["Verify the resolved path: check that <dataset_dir>/<dataset_name> exists, where dataset_dir defaults to the built-in data/ directory unless overridden in the YAML.","Pass an absolute dataset_dir in your training YAML (dataset_dir: /abs/path/to/data) to remove cwd ambiguity.","Fix the dataset_name/file_name entry in dataset_info.json to match the actual file name including extension.","If the file lives elsewhere, move or symlink it into the dataset directory."],"exampleFix":"# before (train.yaml + dataset_info.json)\n# dataset_info.json: \"mydata\": {\"file_name\": \"my_data.jsonl\"}\n# file actually at /datasets/my_data.jsonl\n\n# after\n# dataset_info.json: \"mydata\": {\"file_name\": \"my_data.jsonl\"}\n# train.yaml:\ndataset_dir: /datasets","handlingStrategy":"validation","validationCode":"import os\n\ndef dataset_path_exists(dataset_dir: str, dataset_name: str) -> bool:\n    p = os.path.join(dataset_dir, dataset_name)\n    return os.path.isfile(p) or os.path.isdir(p)","typeGuard":null,"tryCatchPattern":"from datasets import Dataset\ntry:\n    _load_single_dataset(attr, model_args, data_args, training_args)\nexcept ValueError as e:\n    if \"not found\" in str(e):\n        # resolve against an absolute dataset_dir and retry once\n        raise","preventionTips":["Use absolute dataset_dir in training YAMLs.","Run a tiny bootstrap script that verifies every dataset_info.json file entry resolves to an existing path.","Prefer absolute paths in containers/CI where cwd varies."],"tags":["dataset","file-not-found","path","config"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}