spacedriveapp/spacedrive · error · anyhow::Error
Library {} not initialized
Error message
Library {} not initialized What it means
SidecarManager::get_path_builder found no SidecarPathBuilder for the library in its path_builders map. The manager is initialized per library; any compute_path, store, or availability call for an uninitialized or already deinitialized library hits this error. The library_id in the message names the missing entry.
Source
Thrown at core/src/service/sidecar_manager.rs:96
);
Ok(())
}
/// Remove path builder for a library
pub async fn deinit_library(&self, library_id: &Uuid) {
let mut builders = self.path_builders.write().await;
builders.remove(library_id);
info!("Deinitialized sidecar manager for library {}", library_id);
}
/// Get path builder for a library
async fn get_path_builder(&self, library_id: &Uuid) -> Result<Arc<SidecarPathBuilder>> {
let builders = self.path_builders.read().await;
builders
.get(library_id)
.cloned()
.ok_or_else(|| anyhow::anyhow!("Library {} not initialized", library_id))
}
/// Compute sidecar path
pub async fn compute_path(
&self,
library_id: &Uuid,
content_uuid: &Uuid,
kind: &SidecarKind,
variant: &SidecarVariant,
format: &SidecarFormat,
) -> Result<SidecarPath> {
let builder = self.get_path_builder(library_id).await?;
Ok(builder.build(content_uuid, kind, variant, format))
}
/// Check if a sidecar exists in the filesystem
pub async fn exists(
&self,View on GitHub (pinned to 6dfeccf211)
Solutions
- Initialize the sidecar manager for the library (register its path builder) before dispatching sidecar work
- Only schedule sidecar jobs from contexts that hold an open, fully initialized library
- During library close, stop sidecar producers before deinitialize so late callers get a clean cancellation
Defensive patterns
Strategy: validation
Validate before calling
// Track initialized libraries and route sidecar calls through it
if !sidecar_manager.is_initialized(&library_id).await {
sidecar_manager.initialize(&library).await?;
}
sidecar_manager.compute_path(&library_id, ...).await?; Type guard
async fn sidecar_ready(mgr: &SidecarManager, library_id: &Uuid) -> bool {
mgr.path_builders_read().await.contains_key(library_id)
} Try / catch
match sidecar_manager.compute_path(&library_id, content_uuid, kind, variant, format).await {
Err(e) if e.to_string().contains("not initialized") => {
// re-initialize the manager for the library and retry once
}
other => other,
} Prevention
- Initialize the sidecar manager inside library open, before scheduling any sidecar work
- Derive sidecar calls from an open library handle so lifecycle is implicit
- Stop sidecar producers before deinitializing at library close
When it happens
Trigger: Calling sidecar path computation before initialize ran for that library; using the manager after deinitialize_library during library close; a stale SidecarManager handle surviving a library reopen cycle.
Common situations: Startup ordering where scan or thumbnail jobs touch sidecars before the library finishes opening; shutdown races during library close or deletion.
Related errors
- Library not found: {}
- Unknown config key: {}
- No libraries found on remote device. Use 'Share my library'
- Library merging is not yet implemented
- No library selected. Run 'sd library list' to see available
AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16).
Data as JSON: /api/errors/839d434fd0832298.
Report an issue: GitHub.