LGUG2Z/komorebi · error
unable to obtain user's home folder
Error message
unable to obtain user's home folder
What it means
startup_dir() builds the Windows Start Menu Startup folder path by joining fixed AppData segments onto dirs::home_dir(). If the home directory cannot be resolved, it panics with 'unable to obtain user's home folder'. This is used when creating the komorebi.lnk startup shortcut (komorebic startup / enable autostart).
Source
Thrown at komorebic/src/main.rs:1595
GenerateStaticConfig,
/// Generates the komorebi.lnk shortcut in shell:startup to autostart komorebi
EnableAutostart(EnableAutostart),
/// Deletes the komorebi.lnk shortcut in shell:startup to disable autostart
DisableAutostart,
}
// print_query is a helper that queries komorebi and prints the response.
// panics on error.
fn print_query(message: &SocketMessage) {
match send_query(message) {
Ok(response) => println!("{response}"),
Err(error) => panic!("{}", error),
}
}
fn startup_dir() -> eyre::Result<PathBuf> {
let startup = dirs::home_dir()
.expect("unable to obtain user's home folder")
.join("AppData")
.join("Roaming")
.join("Microsoft")
.join("Windows")
.join("Start Menu")
.join("Programs")
.join("Startup");
if !startup.is_dir() {
std::fs::create_dir_all(&startup)?;
}
Ok(startup)
}
#[allow(clippy::too_many_lines, clippy::cognitive_complexity)]
fn main() -> eyre::Result<()> {
let opts: Opts = Opts::parse();View on GitHub (pinned to e0709f02bf)
Solutions
- Run the command from an interactive user session where USERPROFILE is set
- Set USERPROFILE (or HOME) manually in the launching environment
- Create the Startup folder manually if the profile is incomplete and skip shortcut installation
- Verify the Windows profile AppData\Roaming structure exists
Example fix
// before komorebic startup install // after (ensure home resolves first) set USERPROFILE=C:\Users\me komorebic startup install
Defensive patterns
Strategy: try-catch
Validate before calling
# PowerShell guard before installing the startup shortcut
if (-not $env:USERPROFILE -or -not (Test-Path "$env:USERPROFILE\AppData\Roaming")) {
throw "User profile/Roaming unavailable; autostart install would panic"
} Try / catch
// Wrap the invocation and fall back to manual shortcut creation
match run_komorebic("startup install") {
Err(e) if e.contains("home folder") => create_startup_shortcut_manually(),
other => other,
} Prevention
- Install autostart from a logged-in user session
- Ensure USERPROFILE is set when invoking from scripts
- Verify AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup exists
- Create the .lnk manually if the profile is incomplete
When it happens
Trigger: Calling any komorebic command that touches the startup shortcut (e.g. 'komorebic startup install') while dirs::home_dir() returns None because USERPROFILE/HOME is missing.
Common situations: Installing the komorebi autostart shortcut from a service account, CI job, or environment with no USERPROFILE; running under a broken Windows profile without Roaming AppData.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- there is no home directory
- $Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is
- no home directory found
- there is no home directory
- there is no local data directory
AI-assisted analysis of LGUG2Z/komorebi@e0709f02bf (2026-09-06).
Data as JSON: /api/errors/a14b8837d44e5634.
Report an issue: GitHub.