Skip to content

fix(core): use home crate for cross-platform home directory resolution#2031

Open
jeffmaury wants to merge 1 commit into
NVIDIA:mainfrom
jeffmaury:fix/2028-windows-home-dir/jeffmaury
Open

fix(core): use home crate for cross-platform home directory resolution#2031
jeffmaury wants to merge 1 commit into
NVIDIA:mainfrom
jeffmaury:fix/2028-windows-home-dir/jeffmaury

Conversation

@jeffmaury

Copy link
Copy Markdown
Contributor

🏗️ build-from-issue-agent

Summary

Replace all direct std::env::var("HOME") lookups with the home crate, which resolves the home directory correctly on both Unix (HOME) and Windows (USERPROFILE / HOMEDRIVE+HOMEPATH). This fixes the CLI crashing on Windows with "HOME is not set".

Related Issue

Closes #2028

Changes

  • Cargo.toml (workspace): Added home = "0.5" to workspace dependencies
  • crates/openshell-core/Cargo.toml: Added home dependency
  • crates/openshell-core/src/paths.rs: Added pub fn home_dir() helper using home::home_dir(), updated xdg_config_dir(), xdg_state_dir(), xdg_data_dir() to use it, added unit test
  • crates/openshell-core/src/config.rs: Replaced HOME lookups in podman_socket_candidates() and docker_socket_candidates()
  • crates/openshell-cli/src/run.rs: Replaced HOME lookups in XDG state fallback and gcloud ADC resolution
  • crates/openshell-cli/src/ssh.rs: Replaced HOME lookup in user_ssh_config_path()
  • crates/openshell-providers/src/providers/opencode.rs: Replaced HOME lookup in opencode_config_path()
  • crates/openshell-server/src/compute/vm.rs: Replaced HOME lookup in VM driver search dirs
  • crates/openshell-driver-vm/Cargo.toml + src/driver.rs: Added home dep, replaced macOS-gated HOME lookup
  • crates/openshell-driver-podman/Cargo.toml + src/config.rs: Added home dep, replaced macOS-gated HOME lookup

Deviations from Plan

None — implemented as planned

Testing

  • cargo fmt --all -- --check passes
  • Unit test added for home_dir() in paths.rs
  • Existing SSH config test continues to work (the home crate reads HOME when set, so test env var override still functions)

Tests added:

  • Unit: paths::tests::home_dir_returns_ok — verifies home_dir() returns an absolute path on all platforms
  • Integration: N/A — mechanical replacement, no new inter-component interaction
  • E2E: N/A — no changes under e2e/

Note: Full cargo clippy --workspace and cargo test could not be verified locally on Windows due to pre-existing build failures in protobuf-src and the openssh crate (Unix-only). CI will verify on Linux.

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

Documentation updated:

  • None needed — internal implementation fix with no user-facing API or config changes

Replace all direct `std::env::var("HOME")` lookups with the `home` crate,
which resolves the home directory correctly on both Unix (`HOME`) and
Windows (`USERPROFILE` / `HOMEDRIVE`+`HOMEPATH`).

Adds a `home_dir()` helper to `openshell-core::paths` and updates all
call sites across openshell-core, openshell-cli, openshell-providers,
openshell-server, openshell-driver-vm, and openshell-driver-podman.

Closes NVIDIA#2028

Signed-off-by: Jeff MAURY <jmaury@redhat.com>
@copy-pr-bot

copy-pr-bot Bot commented Jun 27, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: openshell CLI fails on Windows — HOME environment variable not set

1 participant