{"record":{"id":"c3a640848e503103","repo":"spacedriveapp/spacedrive","slug":"no-library-selected-c3a640","errorCode":null,"errorMessage":"No library selected","messagePattern":"No library selected","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"apps/cli/src/domains/spaces/mod.rs","lineNumber":79,"sourceCode":"\t\t\t\tCell::new(&space.icon),\n\t\t\t\tCell::new(&space.color),\n\t\t\t\tCell::new(space.order),\n\t\t\t]);\n\t\t}\n\n\t\tprintln!(\"{table}\");\n\t}\n\n\tOk(())\n}\n\nasync fn get_layout(ctx: &Context, space_id: String) -> Result<()> {\n\tuse sd_core::ops::spaces::{SpaceLayoutQuery, SpaceLayoutQueryInput};\n\tuse uuid::Uuid;\n\n\tlet library_id = ctx\n\t\t.library_id\n\t\t.ok_or_else(|| anyhow::anyhow!(\"No library selected\"))?;\n\n\tlet space_uuid = Uuid::parse_str(&space_id)?;\n\n\tlet input = SpaceLayoutQueryInput {\n\t\tspace_id: space_uuid,\n\t};\n\tlet response: serde_json::Value = ctx.core.query(&input, Some(library_id)).await?;\n\n\tprintln!(\"\\nRaw layout response:\");\n\tprintln!(\"{}\", serde_json::to_string_pretty(&response)?);\n\n\tOk(())\n}\n","sourceCodeStart":61,"sourceCodeEnd":93,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/apps/cli/src/domains/spaces/mod.rs#L61-L93","documentation":"Thrown by 'sd spaces layout <space_id>' when ctx.library_id is None - identical root cause to the spaces list error, with a terser message. The layout query (SpaceLayoutQueryInput) is library-scoped, so a current library must be set in the CLI config before it can run.","triggerScenarios":"Running 'sd spaces layout <space_id>' before any 'sd library create'/'sd library switch'; config reset or stale after the referenced library was removed.","commonSituations":"Fresh install; scripting a sequence of commands where the library switch step was skipped or failed earlier.","solutions":["Run 'sd library list' and 'sd library switch <id>' to set a current library","Create a library first if none exists ('sd library create')","Then re-run 'sd spaces layout <space_id>'"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let Some(library_id) = ctx.get_current_library_id() else {\n    eprintln!(\"No current library. Run 'sd library switch <id>'.\");\n    return Ok(());\n};","typeGuard":"fn has_current_library(ctx: &Context) -> bool {\n    ctx.library_id.is_some()\n}","tryCatchPattern":null,"preventionTips":["Set the current library before any spaces command","Also pre-validate the space_id argument: Uuid::parse_str(&space_id) fails with its own error if malformed","Centralize the library check instead of duplicating it per subcommand"],"tags":["cli","spaces","library","config"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}