Skip to content

Commit 3935a41

Browse files
authored
try using user local homebrew (#24)
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
1 parent 2bf5e01 commit 3935a41

2 files changed

Lines changed: 6 additions & 59 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,8 @@ This action performs the following steps:
5252
- Enables the Windows Hypervisor Platform on Windows.
5353
- Sets up environment variables needed to build / run tests based on the machine's configuration.
5454

55-
Runners need Bash 5 and rustup or curl. On macOS, the action discovers Homebrew
56-
on PATH or in its standard Apple Silicon and Intel locations, installing it
57-
noninteractively with the official installer when missing. If an existing
58-
installation is not writable, the action reruns the official installer to repair
59-
its permissions and checks them again before continuing. Installation and repair
60-
require the runner user to have the permissions required by that installer,
61-
including noninteractive sudo access when ownership changes are needed.
55+
Runners need Bash 5 and rustup or curl. On macOS, the action uses user-local
56+
Homebrew at `$HOME/.homebrew` without changing the system Homebrew.
6257
The Rust setup action installs rustup when missing and Bash through Homebrew
6358
on macOS.
6459

‎action.yml‎

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -15,61 +15,13 @@ runs:
1515
using: composite
1616
steps:
1717

18-
- name: Ensure Homebrew is available (macOS)
18+
- name: Set up user-local Homebrew (macOS)
1919
if: ${{ runner.os == 'macOS' }}
2020
run: |
21-
find_brew() {
22-
local candidate
23-
if candidate="$(command -v brew)" && [ -x "$candidate" ]; then
24-
echo "$candidate"
25-
return 0
26-
fi
27-
for candidate in /opt/homebrew/bin/brew /usr/local/bin/brew; do
28-
if [ -x "$candidate" ]; then
29-
echo "$candidate"
30-
return 0
31-
fi
32-
done
33-
return 1
34-
}
35-
36-
brew_is_writable() {
37-
prefix="$("$brew" --prefix)" || return 1
38-
repository="$("$brew" --repository)" || return 1
39-
for directory in "$prefix" "$repository" \
40-
"$prefix/Cellar" "$prefix/Frameworks" "$prefix/bin" \
41-
"$prefix/etc" "$prefix/etc/bash_completion.d" \
42-
"$prefix/include" "$prefix/lib" "$prefix/lib/pkgconfig" \
43-
"$prefix/opt" "$prefix/sbin" "$prefix/share" \
44-
"$prefix/share/doc" "$prefix/share/man" \
45-
"$prefix/share/man/man1" "$prefix/share/man/man3" \
46-
"$prefix/share/man/man5" "$prefix/share/man/man7" \
47-
"$prefix/share/zsh" "$prefix/share/zsh/site-functions" \
48-
"$prefix/var/homebrew" "$prefix/var/homebrew/linked" \
49-
"$prefix/var/homebrew/locks"; do
50-
if [ -e "$directory" ] && [ ! -w "$directory" ]; then
51-
echo "Homebrew directory is not writable: $directory" >&2
52-
return 1
53-
fi
54-
done
55-
}
56-
57-
if ! brew="$(find_brew)" || ! brew_is_writable; then
58-
echo "Installing or repairing Homebrew for $(id -un)."
59-
installer="$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
60-
NONINTERACTIVE=1 /bin/bash -c "$installer"
61-
if ! brew="$(find_brew)"; then
62-
echo "::error::Homebrew installer completed but brew was not found."
63-
exit 1
64-
fi
21+
prefix="$HOME/.homebrew"
22+
if [ ! -x "$prefix/bin/brew" ]; then
23+
git clone --depth=1 https://github.com/Homebrew/brew.git "$prefix"
6524
fi
66-
67-
if ! brew_is_writable; then
68-
echo "::error::Homebrew is still not writable after running its installer. Check runner sudo permissions and Homebrew ownership."
69-
exit 1
70-
fi
71-
72-
prefix="$("$brew" --prefix)"
7325
printf '%s\n' "$prefix/bin" "$prefix/sbin" >> "$GITHUB_PATH"
7426
shell: bash
7527

0 commit comments

Comments
 (0)