spacedriveapp/spacedrive · error · anyhow::Error

Library '{}' not found

Error message

Library '{}' not found

What it means

Returned by SyncResolver::calculate_operations when the entry row for conduit.source_entry_id no longer exists. Unlike the create-time validation in conduit.rs, this fires at sync time: the conduit row persists but its source endpoint has been deleted from the entries table.

Source

Thrown at apps/cli/src/context.rs:95

			.set_current_library(library_id, &self.data_dir)
	}

	/// Switch to a library by name
	pub async fn switch_to_library_named(&mut self, name: &str) -> Result<()> {
		let libs: Vec<sd_core::ops::libraries::list::output::LibraryInfo> = execute_core_query!(
			self,
			sd_core::ops::libraries::list::query::ListLibrariesInput {
				include_stats: false
			}
		);

		if let Some(lib) = libs.iter().find(|lib| lib.name == name) {
			self.library_id = Some(lib.id);
			self.cli_config
				.set_current_library(lib.id, &self.data_dir)?;
			Ok(())
		} else {
			anyhow::bail!("Library '{}' not found", name)
		}
	}

	/// Get current library info
	pub async fn get_current_library_info(
		&self,
	) -> Result<Option<sd_core::ops::libraries::info::output::LibraryInfoOutput>> {
		if let Some(_library_id) = self.library_id {
			let input = sd_core::ops::libraries::info::query::LibraryInfoQueryInput {};
			let info: sd_core::ops::libraries::info::output::LibraryInfoOutput =
				execute_query!(self, input);
			Ok(Some(info))
		} else {
			Ok(None)
		}
	}

	/// Require a current library (error if none set)

View on GitHub (pinned to 6dfeccf211)

Solutions

  1. Check the reference: SELECT source_entry_id FROM sync_conduit WHERE id = <id>; then SELECT id FROM entry WHERE id = <that>.
  2. If the directory still exists on disk, re-index its location to recreate the entry, then update the conduit to the new entry id.
  3. If it is gone for good, delete the conduit (delete_conduit) to stop sync attempts.
Defensive patterns

Strategy: validation

Validate before calling

// Validate conduit endpoints before calculating operations.
async fn source_root_exists(db: &DatabaseConnection, c: &sync_conduit::Model) -> Result<bool> {
    Ok(entry::Entity::find_by_id(c.source_entry_id)
        .one(db)
        .await?
        .is_some())
}

Try / catch

match svc.sync_now(conduit_id).await {
    Ok(h) => Ok(h),
    Err(e) if e.to_string().contains("Source entry not found") => {
        disable_or_delete_conduit(conduit_id); // stop retrying a broken pair
        Err(e)
    }
    Err(e) => Err(e),
}

Prevention

When it happens

Trigger: Running sync_now (which calls resolver.calculate_operations) on a conduit whose source directory entry was deleted — source folder removed from disk and reindexed away, or the entry row manually deleted.

Common situations: User deletes or renames the synced folder outside the app; a reindex prunes entries for unmounted/removed locations; DB restored from a backup that dropped entries but kept conduits.

Related errors


AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16). Data as JSON: /api/errors/e86e5e724a971b69. Report an issue: GitHub.