-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathbrew-wrapper.sh
More file actions
27 lines (24 loc) · 1.07 KB
/
brew-wrapper.sh
File metadata and controls
27 lines (24 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash
# Wrapper script for brew that runs as linuxbrew user when called by root
# This is needed because Homebrew refuses to run as root
REAL_BREW="/home/linuxbrew/.linuxbrew/bin/brew"
# Check if Homebrew is actually installed
if [ ! -x "$REAL_BREW" ]; then
echo "ERROR: Homebrew is not installed (likely due to unsupported CPU - requires SSSE3)." >&2
echo "Some OpenClaw skills that depend on CLI tools (gemini, aider, etc.) will not work." >&2
echo "Consider using a newer CPU or installing dependencies manually." >&2
exit 127
fi
if [ "$(id -u)" = "0" ]; then
# Running as root - use sudo to run as linuxbrew user
# Preserve necessary environment variables and properly pass all arguments
exec sudo -u linuxbrew \
HOMEBREW_NO_AUTO_UPDATE="${HOMEBREW_NO_AUTO_UPDATE:-1}" \
HOMEBREW_NO_ANALYTICS="${HOMEBREW_NO_ANALYTICS:-1}" \
HOME="/home/linuxbrew" \
PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:$PATH" \
"$REAL_BREW" "$@"
else
# Not root - run directly
exec "$REAL_BREW" "$@"
fi