Skip to content

Commit

Permalink
fix: windows home directory (#608)
Browse files Browse the repository at this point in the history
HOMEPATH isn't always set. For example https://buildkite.com/bazel/bazel-bazel-examples/builds/2163#018b1a9d-0127-461f-8200-e89894397f35
USERPROFILE seems more widely documented as being the equivalent of HOME
  • Loading branch information
alexeagle authored Oct 10, 2023
1 parent c6b39ab commit f489b3c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/private/repo_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def _get_env_var(rctx, name, default):
"""

# On Windows, the HOME environment variable is named differently.
# See https://pureinfotech.com/list-environment-variables-windows-10/
# See https://en.wikipedia.org/wiki/Home_directory#Default_home_directory_per_operating_system
if name == "HOME" and _is_windows(rctx):
name = "HOMEPATH"
name = "USERPROFILE"
if name in rctx.os.environ:
return rctx.os.environ[name]
return default
Expand Down

0 comments on commit f489b3c

Please sign in to comment.