{"record":{"id":"57bc00974c3d8a55","repo":"gitbutlerapp/gitbutler","slug":"could-not-determine-home-directory-57bc00","errorCode":null,"errorMessage":"Could not determine home directory","messagePattern":"Could not determine home directory","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/but/src/command/skill/mod.rs","lineNumber":413,"sourceCode":"/// Expand tilde in path to home directory\nfn expand_tilde(path_str: &str) -> Option<PathBuf> {\n    if path_str == \"~\" || path_str.starts_with(\"~/\") || path_str.starts_with(\"~\\\\\") {\n        home_dir().map(|home| {\n            if path_str == \"~\" {\n                home\n            } else {\n                home.join(&path_str[2..])\n            }\n        })\n    } else {\n        None\n    }\n}\n\n/// Get the base directory for installation (repo root or home directory)\nfn get_base_dir(ctx: Option<&mut Context>, global: bool) -> Result<PathBuf> {\n    if global {\n        home_dir().ok_or_else(|| anyhow::anyhow!(\"Could not determine home directory\"))\n    } else {\n        let ctx = ctx.ok_or_else(|| {\n            anyhow::anyhow!(\n                \"Not in a git repository. Use --global to install globally, or run from within a repository.\"\n            )\n        })?;\n        let repo = ctx.repo.get()?;\n        repo.workdir()\n            .ok_or_else(|| anyhow::anyhow!(\"Not in a Git repository\"))\n            .map(|p| p.to_path_buf())\n    }\n}\n\n/// Replace version in SKILL.md content\nfn inject_version(content: &str, version: &str) -> String {\n    // Handle different line endings (Unix \\n, Windows \\r\\n, or old Mac \\r)\n    let frontmatter_end = content\n        .find(\"---\\n\\n\")","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/skill/mod.rs#L395-L431","documentation":"`but skill install --global` computes its install base from the user's home directory. When the platform home lookup fails (HOME on Unix or USERPROFILE on Windows unset or empty), installation cannot proceed and this error is returned.","triggerScenarios":"Running `but skill install --global` in an environment without HOME/USERPROFILE: minimal containers, CI runners with sanitized env, systemd units, cron jobs.","commonSituations":"Docker images that never set HOME; service accounts; scripts run with env -i or heavily scrubbed environments.","solutions":["Set HOME explicitly (export HOME=/home/user, or USERPROFILE on Windows) and retry","Install per-repository instead: run the command without --global from inside a git repository","In containers, set ENV HOME=/root in the image or pass -e HOME=... at run time"],"exampleFix":"# before\ndocker run img but skill install my-skill --global   # HOME unset -> error\n# after\ndocker run -e HOME=/root img but skill install my-skill --global","handlingStrategy":"validation","validationCode":"if std::env::var_os(\"HOME\").is_none() && std::env::var_os(\"USERPROFILE\").is_none() {\n    anyhow::bail!(\"HOME is not set; global skill install needs a home directory\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set HOME/USERPROFILE in scripts, services, and container images","Prefer repo-local installs in headless environments"],"tags":["skill","home-directory","environment","global-install","containers"],"backgroundTag":"missing-home-env-var","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}