{"record":{"id":"19e29f0ba071ad3c","repo":"BoundaryML/baml","slug":"profiling-store-is-in-use","errorCode":null,"errorMessage":"profiling store is in use: {}","messagePattern":"profiling store is in use: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/clean_command.rs","lineNumber":36,"sourceCode":"        let project_root = crate::project_load::find_project_root_from(self.from.as_deref())?\n            .unwrap_or(std::env::current_dir().context(\"failed to resolve current directory\")?);\n        // Same resolution rule as the producer and `baml query`:\n        // BAML_PROFILE_DIR wins, else the project store. Resolving this\n        // differently would report \"Clean\" while leaving recorded data in\n        // the directory the profiler actually wrote to.\n        let profiles_root =\n            bex_events::prof::backend::ProfilerSession::resolve_store_root(&project_root);\n        match bex_events::prof::backend::clean_profiles_v1(&profiles_root) {\n            Ok(removed) => {\n                let reporter = crate::reporter::Reporter::new();\n                reporter.status(\n                    if removed { \"Removed\" } else { \"Clean\" },\n                    profiles_root.display().to_string(),\n                );\n                Ok(crate::ExitCode::Success)\n            }\n            Err(bex_events::prof::backend::CleanProfilesError::InUse) => {\n                bail!(\"profiling store is in use: {}\", profiles_root.display())\n            }\n            // Cleanup refuses any root not shaped `.../.baml/profiles-v1`,\n            // so it cannot delete an arbitrary BAML_PROFILE_DIR. Say so\n            // instead of surfacing the bare `InvalidRoot`.\n            Err(bex_events::prof::backend::CleanProfilesError::InvalidRoot)\n                if std::env::var_os(\"BAML_PROFILE_DIR\").is_some() =>\n            {\n                bail!(\n                    \"BAML_PROFILE_DIR points at {}, which is not a `.baml/profiles-v1` store; \\\n                     remove it manually\",\n                    profiles_root.display()\n                )\n            }\n            Err(error) => Err(anyhow::Error::new(error).context(format!(\n                \"failed to clean segmented profiler data at {}\",\n                profiles_root.display()\n            ))),\n        }","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/clean_command.rs#L18-L54","documentation":"`baml clean` deletes the segmented profiler data store, but the backend refuses when the profiling store is currently in use (CleanProfilesError::InUse). The command bails with the profiles root path so you know which store is busy.","triggerScenarios":"Running `baml clean` (or clean --profiles) while another baml process holds the profiling store open — e.g. a concurrent `baml dev` session actively writing profiles under `.../.baml/profiles-v1`.","commonSituations":"Trying to clean profiles while a dev server or test run with BAML_PROFILING enabled is still running; leftover lock from a crashed process still holding the store.","solutions":["Stop the running baml process (dev server, test run) that is writing profile data, then re-run clean.","Check for orphaned baml processes (ps aux | grep baml) and kill them before cleaning.","If a crashed process left the lock, remove the store manually: rm -rf <project>/.baml/profiles-v1."],"exampleFix":"# before\nbaml clean  # fails while `baml dev` is running\n# after\n# stop baml dev first, then:\nbaml clean","handlingStrategy":"retry","validationCode":"// shell: ensure no baml process holds the store before cleaning\npgrep -f 'baml (dev|test)' && echo \"stop running baml processes first\" || baml clean","typeGuard":null,"tryCatchPattern":"// retry after stopping writers\ntry {\n  await run('baml clean');\n} catch (e) {\n  if (String(e).includes('profiling store is in use')) {\n    await stopBamlProcesses();\n    await run('baml clean');\n  }\n}","preventionTips":["Stop baml dev/test sessions before cleaning profiles","Check for orphaned baml processes after crashes","Schedule profile cleanup only when no builds are active"],"tags":["cli","profiling","file-lock","cleanup"],"backgroundTag":"resource-in-use","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"}