{"record":{"id":"3fdc507318cbd941","repo":"BoundaryML/baml","slug":"failed-to-load-project-files","errorCode":null,"errorMessage":"Failed to load project files: {}","messagePattern":"Failed to load project files: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_server/src/session.rs","lineNumber":253,"sourceCode":"        // Drop moved \"baml_src\" directories, otherwise the project_updates\n        // code below will fail trying to read directories that no longer exist.\n        let removed_baml_src_dirs = baml_src_projects\n            .keys()\n            .filter(|project_root| !project_root.exists())\n            .cloned()\n            .collect::<Vec<_>>();\n        for baml_src_dir in &removed_baml_src_dirs {\n            baml_src_projects.remove(baml_src_dir);\n        }\n\n        let project_updates: Vec<HashMap<_, _>> = baml_src_projects\n            .iter_mut()\n            .map(|(project_root, project)| {\n                let files_map = project\n                    .lock()\n                    .baml_project\n                    .load_files()\n                    .map_err(|e| anyhow::anyhow!(\"Failed to load project files: {}\", e))?;\n\n                tracing::info!(\n                    \"Loaded {} files for project root: {:?}\",\n                    files_map.len(),\n                    project_root\n                );\n\n                {\n                    let default_flags = vec![\"beta\".to_string()];\n                    project.lock().update_runtime(\n                        notifier.clone(),\n                        self.baml_settings\n                            .feature_flags\n                            .as_ref()\n                            .unwrap_or(&default_flags),\n                    )\n                }\n                .map_err(|e| {","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_server/src/session.rs#L235-L271","documentation":"Session::reload reloads all project files into each BamlProject via load_files(); if reading/parsing the project's files fails for any project, reload aborts with 'Failed to load project files'. This wraps the underlying I/O or parse error.","triggerScenarios":"load_files() returns Err for a project root: baml_src directory missing/unreadable, permission errors, invalid symlinks, or underlying file parsing failures during a settings/file change triggered reload.","commonSituations":"baml_src folder renamed or deleted while the LSP is running; project opened on a network mount that went offline; permission changes after a git checkout; workspace with no valid baml_src contents.","solutions":["Check the inner error message for the root cause (missing dir vs permissions vs parse)","Restore or recreate the baml_src directory for the affected project root","Fix filesystem permissions so the server process can read the project files","Restart the language server after restoring the project structure"],"exampleFix":"// before: project deleted under running server\n$ mv baml_src baml_src_backup  # LSP reload fails\n// after\n$ mv baml_src_backup baml_src  # reload succeeds","handlingStrategy":"retry","validationCode":"// pre-check project readability before triggering reload\nfor (const root of projectRoots) fs.accessSync(path.join(root, 'baml_src'), fs.constants.R_OK);","typeGuard":"function projectReadable(root: string): boolean { try { fs.accessSync(path.join(root, 'baml_src'), fs.constants.R_OK); return true; } catch { return false; } }","tryCatchPattern":"try { await triggerReload(); } catch (e) { if (String(e).includes('Failed to load project files')) { await waitForFsStable(); await triggerReload(); } else throw e; }","preventionTips":["Keep baml_src present and readable while the LSP runs","Fix permissions after checkouts/mount changes","Retry reload after transient network filesystem errors","Read the inner error to target the root cause"],"tags":["lsp","filesystem","rust","reload"],"backgroundTag":"file-read-failed","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}