fix(core): use home crate for cross-platform home directory resolution#2031
Open
jeffmaury wants to merge 1 commit into
Open
fix(core): use home crate for cross-platform home directory resolution#2031jeffmaury wants to merge 1 commit into
jeffmaury wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace all direct
std::env::var("HOME")lookups with thehomecrate, 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): Addedhome = "0.5"to workspace dependenciescrates/openshell-core/Cargo.toml: Addedhomedependencycrates/openshell-core/src/paths.rs: Addedpub fn home_dir()helper usinghome::home_dir(), updatedxdg_config_dir(),xdg_state_dir(),xdg_data_dir()to use it, added unit testcrates/openshell-core/src/config.rs: ReplacedHOMElookups inpodman_socket_candidates()anddocker_socket_candidates()crates/openshell-cli/src/run.rs: ReplacedHOMElookups in XDG state fallback and gcloud ADC resolutioncrates/openshell-cli/src/ssh.rs: ReplacedHOMElookup inuser_ssh_config_path()crates/openshell-providers/src/providers/opencode.rs: ReplacedHOMElookup inopencode_config_path()crates/openshell-server/src/compute/vm.rs: ReplacedHOMElookup in VM driver search dirscrates/openshell-driver-vm/Cargo.toml+src/driver.rs: Addedhomedep, replaced macOS-gatedHOMElookupcrates/openshell-driver-podman/Cargo.toml+src/config.rs: Addedhomedep, replaced macOS-gatedHOMElookupDeviations from Plan
None — implemented as planned
Testing
cargo fmt --all -- --checkpasseshome_dir()inpaths.rshomecrate readsHOMEwhen set, so test env var override still functions)Tests added:
paths::tests::home_dir_returns_ok— verifieshome_dir()returns an absolute path on all platformse2e/Note: Full
cargo clippy --workspaceandcargo testcould not be verified locally on Windows due to pre-existing build failures inprotobuf-srcand theopensshcrate (Unix-only). CI will verify on Linux.Checklist
Documentation updated: