diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 162cccd..11c560e 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1467,7 +1467,11 @@ fn expand_host_path(path: &str, home: &Path, cwd: &Path) -> PathBuf { fn defaults(options: &BaseOptions) -> io::Result<(PathBuf, PathBuf)> { let home = match &options.home { Some(home) => home.clone(), - None => PathBuf::from(std::env::var("HOME").unwrap_or_default()), + None => PathBuf::from( + std::env::var("HOME") + .or_else(|_| std::env::var("USERPROFILE")) + .unwrap_or_default(), + ), }; let cwd = match &options.cwd { Some(cwd) => cwd.clone(), diff --git a/ts/src/index.ts b/ts/src/index.ts index 71b69da..dc0ff21 100644 --- a/ts/src/index.ts +++ b/ts/src/index.ts @@ -10,6 +10,7 @@ import { stat, writeFile, } from "node:fs/promises"; +import { homedir } from "node:os"; import { dirname, join, relative, resolve, sep } from "node:path"; import { fileURLToPath } from "node:url"; import { defaultHostsSpecJson } from "./hosts.generated.js"; @@ -415,7 +416,7 @@ export async function detectHosts( options: BaseOptions & { scope?: Scope } = {}, ): Promise { const spec = await loadHostSpec(options.hostsFile); - const home = options.home ?? process.env.HOME ?? ""; + const home = options.home ?? homedir(); const cwd = options.cwd ?? process.cwd(); const detected: Host[] = []; @@ -678,7 +679,7 @@ export async function resolveInstallTargets( detectedHostIds: string[]; }> { const spec = await loadHostSpec(options.hostsFile); - const home = options.home ?? process.env.HOME ?? ""; + const home = options.home ?? homedir(); const cwd = options.cwd ?? process.cwd(); const agents = options.agents ?? defaultAgents; const resolved =