{"record":{"id":"1255704c56f3ea80","repo":"sinelaw/fresh","slug":"home-directory-not-found","errorCode":null,"errorMessage":"home directory not found","messagePattern":"home directory not found","errorType":"exception","errorClass":"io::Error (NotFound)","httpStatus":null,"severity":"error","filePath":"crates/fresh-editor-core/src/model/filesystem.rs","lineNumber":688,"sourceCode":"    fn remote_channel_id(&self) -> Option<u64> {\n        None\n    }\n\n    /// A handle notified once per successful transport hot-swap of the backing\n    /// agent channel. `None` for local filesystems. The editor awaits this to\n    /// drive event-driven reconnect handling (respawning embedded terminals)\n    /// instead of polling `is_remote_connected()`.\n    fn remote_reconnect_notify(&self) -> Option<std::sync::Arc<tokio::sync::Notify>> {\n        None\n    }\n\n    /// Get the home directory for this filesystem\n    ///\n    /// For local filesystems, returns the local home directory.\n    /// For remote filesystems, returns the remote home directory.\n    fn home_dir(&self) -> io::Result<PathBuf> {\n        dirs::home_dir()\n            .ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, \"home directory not found\"))\n    }\n\n    // ========================================================================\n    // Search Operations\n    // ========================================================================\n\n    /// Search a file on disk for a pattern, returning one batch of matches.\n    ///\n    /// Call repeatedly with the same cursor until `cursor.done` is true.\n    /// Each call searches one chunk; the cursor tracks position and line\n    /// numbers across calls.\n    ///\n    /// The search runs where the data lives: `StdFileSystem` reads and\n    /// scans locally; `RemoteFileSystem` sends a stateless RPC to the\n    /// remote agent.  Only matches cross the network.\n    ///\n    /// For searching an already-open buffer with unsaved edits, use\n    /// `TextBuffer::search_scan_all` which reads from the piece tree.","sourceCodeStart":670,"sourceCodeEnd":706,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor-core/src/model/filesystem.rs#L670-L706","documentation":"The Filesystem trait's home_dir() fails when dirs::home_dir() returns None, i.e. the user's home directory cannot be determined. Local filesystems read $HOME, remote filesystems resolve the remote home; either may be unavailable. Many path expansions (~) depend on this.","triggerScenarios":"Calling home_dir() on a local filesystem with $HOME unset (and no passwd entry), or on a remote filesystem whose session has no home.","commonSituations":"Commands run from cron/systemd with a minimal environment; containers running as a user without /etc/passwd entry.","solutions":["Set HOME in the environment before running the editor.","For services, specify Environment=HOME=/home/user in the unit or wrapper script.","If a remote filesystem, verify the remote session resolves a home directory."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if std::env::var(\"HOME\").map(|h| h.is_empty()).unwrap_or(true) {\n    eprintln!(\"HOME is unset; ~ expansion will fail\");\n}","typeGuard":null,"tryCatchPattern":"match fs.home_dir() {\n    Ok(home) => home,\n    Err(e) if e.kind() == std::io::ErrorKind::NotFound => {\n        PathBuf::from(std::env::var(\"HOME\").unwrap_or_else(|_| \"/tmp\".into()))\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Set HOME in service, cron, and container environments","Check home_dir() once at startup and warn early","Avoid ~ expansion until home_dir() has succeeded"],"tags":["environment","filesystem","io"],"backgroundTag":"missing-env-var","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}