Skip to content

Commit 1086d13

Browse files
committed
fix(install): use arch-aware install dir and mkdir -p to fix fresh macOS
On Apple Silicon new machines /usr/local/bin does not exist; Homebrew installs to /opt/homebrew instead. The -w check returned false for the missing directory, causing sudo mv to also fail with "No such file or directory". Now selects /opt/homebrew/bin on arm64 (when present) and falls back to /usr/local/bin on x86_64, creating the directory first if it does not exist.
1 parent 42fa38a commit 1086d13

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

src/lib/server/install-script.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,13 @@ describe('generateInstallScript', () => {
196196

197197
expect(script).toContain('openboot install "testuser/my-config" "$@"');
198198
});
199+
200+
it('should use /opt/homebrew/bin on arm64 and mkdir -p if dir is missing', () => {
201+
const script = generateInstallScript('testuser', 'my-config');
202+
203+
expect(script).toContain('/opt/homebrew/bin');
204+
expect(script).toContain('mkdir -p');
205+
// must not assume /usr/local/bin always exists
206+
expect(script).not.toMatch(/sudo mv \/tmp\/openboot-install \/usr\/local\/bin\/openboot/);
207+
});
199208
});

src/lib/server/install-script.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,21 @@ install_openboot() {
227227
curl -fsSL "\$binary_url" -o /tmp/openboot-install
228228
chmod +x /tmp/openboot-install
229229
230-
if [[ -w "/usr/local/bin" ]]; then
231-
mv /tmp/openboot-install /usr/local/bin/openboot
230+
local install_dir
231+
if [[ "\$arch_name" == "arm64" ]] && [[ -d "/opt/homebrew/bin" ]]; then
232+
install_dir="/opt/homebrew/bin"
232233
else
233-
sudo mv /tmp/openboot-install /usr/local/bin/openboot
234+
install_dir="/usr/local/bin"
235+
fi
236+
237+
if [[ ! -d "\$install_dir" ]]; then
238+
sudo mkdir -p "\$install_dir"
239+
fi
240+
241+
if [[ -w "\$install_dir" ]]; then
242+
mv /tmp/openboot-install "\$install_dir/openboot"
243+
else
244+
sudo mv /tmp/openboot-install "\$install_dir/openboot"
234245
fi
235246
236247
echo ""

0 commit comments

Comments
 (0)