{"record":{"id":"86e6a5ac367d9e3c","repo":"spacedriveapp/spacedrive","slug":"sd-library-id-environment-variable-must-be-set","errorCode":null,"errorMessage":"SD_LIBRARY_ID environment variable must be set","messagePattern":"SD_LIBRARY_ID environment variable must be set","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/gpui-photo-grid/src/main.rs","lineNumber":16,"sourceCode":"mod photo_grid_view;\n\nuse gpui::*;\nuse photo_grid_view::PhotoGridView;\nuse std::env;\nuse std::sync::Arc;\n\nfn main() {\n    env_logger::init();\n\n    // Get configuration from environment\n    let socket_addr = env::var(\"SD_SOCKET_ADDR\").unwrap_or_else(|_| \"127.0.0.1:6969\".to_string());\n\n    let http_url = env::var(\"SD_HTTP_URL\").unwrap_or_else(|_e| \"http://127.0.0.1:56851\".to_string());\n\n    let library_id = env::var(\"SD_LIBRARY_ID\").expect(\"SD_LIBRARY_ID environment variable must be set\");\n\n    let initial_path = env::var(\"SD_INITIAL_PATH\").unwrap_or_else(|_e| \"/Users/jamespine/Desktop\".to_string());\n\n    println!(\"Starting GPUI Photo Grid\");\n    println!(\"  Socket: {}\", socket_addr);\n    println!(\"  HTTP: {}\", http_url);\n    println!(\"  Library: {}\", library_id);\n    println!(\"  Path: {}\", initial_path);\n\n    // Create HTTP client for image loading\n    let http_client = Arc::new(\n        reqwest_client::ReqwestClient::user_agent(\"spacedrive-gpui\")\n            .expect(\"Failed to create HTTP client\"),\n    );\n\n    Application::new()\n        .with_http_client(http_client)\n        .run(move |cx: &mut App| {","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/spacedriveapp/spacedrive/blob/6dfeccf2113039e35f2ce735f945e70dc3e4ea45/apps/gpui-photo-grid/src/main.rs#L1-L34","documentation":"gpui-photo-grid is a developer playground app that renders one library as a grid; main() panics at startup unless SD_LIBRARY_ID is set. Unlike SD_SOCKET_ADDR, SD_HTTP_URL, and SD_INITIAL_PATH, which have hard-coded defaults, the library id has no fallback because the view is meaningless without a target library.","triggerScenarios":"cargo run inside apps/gpui-photo-grid without environment variables; launching the binary directly instead of through the repo helper/just recipe that injects daemon env; running against a daemon whose libraries were wiped.","commonSituations":"First run of the playground app on a fresh clone; CI or scripted runs that only set the other three SD_* variables.","solutions":["Set the variable to an existing library id: SD_LIBRARY_ID=<uuid> cargo run -p gpui-photo-grid","List libraries first: cargo run --bin sd-cli -- libraries list (or the equivalent CLI command) to copy the id","Check the repo justfile/scripts for the canonical launch command that wires all SD_* variables"],"exampleFix":"// before: silent requirement, panics with a bare expect\nlet library_id = env::var(\"SD_LIBRARY_ID\").expect(\"SD_LIBRARY_ID environment variable must be set\");\n\n// after: actionable startup error listing available ids\nlet library_id = env::var(\"SD_LIBRARY_ID\").unwrap_or_else(|_| {\n    eprintln!(\"SD_LIBRARY_ID is required. Get ids via: sd-cli libraries list\");\n    std::process::exit(2);\n});","handlingStrategy":"validation","validationCode":"let library_id = match env::var(\"SD_LIBRARY_ID\") {\n    Ok(v) if !v.trim().is_empty() => v,\n    _ => {\n        eprintln!(\"SD_LIBRARY_ID is required (get ids via: sd-cli libraries list)\");\n        std::process::exit(2);\n    }\n};","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Launch the playground app through the repo's helper script that sets all SD_* variables","Keep a shell snippet exporting the four SD_* vars for the daemon you test against","Prefer fail-fast env checks with actionable messages over bare expect"],"tags":["environment","configuration","panic","gpui"],"backgroundTag":null,"analyzedSha":"6dfeccf2113039e35f2ce735f945e70dc3e4ea45","analyzedAt":"2026-08-16T11:26:17.074Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}