Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bin/brew: handle missing $HOME. #15818

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion bin/brew
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,30 @@ fi
if [[ -n "${XDG_CONFIG_HOME-}" ]]
then
HOMEBREW_USER_CONFIG_HOME="${XDG_CONFIG_HOME}/homebrew"
else
elif [[ -n "${HOME-}" ]]
then
HOMEBREW_USER_CONFIG_HOME="${HOME}/.homebrew"
elif [[ -n "${USER-}" ]]
then
if [[ "${OSTYPE}" == "darwin"* ]]
then
HOMEBREW_USER_CONFIG_HOME="/Users/${USER}/.homebrew"
else
HOMEBREW_USER_CONFIG_HOME="/home/${USER}/.homebrew"
fi
elif [[ -n "${LOGNAME-}" ]]
then
if [[ "${OSTYPE}" == "darwin"* ]]
then
HOMEBREW_USER_CONFIG_HOME="/Users/${LOGNAME}/.homebrew"
else
HOMEBREW_USER_CONFIG_HOME="/home/${LOGNAME}/.homebrew"
fi
else
echo "Error: \$HOME or \$USER or \$LOGNAME must be set to run brew." >&2
exit 1
fi

if [[ -f "${HOMEBREW_USER_CONFIG_HOME}/brew.env" ]]
then
# only load HOMEBREW_*=* lines
Expand Down