Skip to content

Commit 6294c32

Browse files
committed
fix: fix make gnubin directory on MacOS ARM
1 parent 2e807b3 commit 6294c32

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

packages/setup-brew/src/install.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { tmpdir } from "os"
2-
import { dirname } from "path"
2+
import { dirname, join } from "path"
33
import { type AddPathOptions, addPath } from "envosman"
44
import { execaSync } from "execa"
55
import { DownloaderHelper } from "node-downloader-helper"
@@ -64,23 +64,33 @@ export async function setupBrew(options: SetupBrewOptions = {}): Promise<Install
6464
return { binDir }
6565
}
6666

67+
/**
68+
* Get the path to the bin directory of brew
69+
* @returns {string} The path where brew binary is installed
70+
*
71+
* Based on the installation script from https://brew.sh
72+
*/
73+
export function getBrewBinDir() {
74+
return join(getBrewDir(), "bin")
75+
}
76+
6777
/**
6878
* Get the path where brew is installed
6979
* @returns {string} The path where brew is installed
7080
*
7181
* Based on the installation script from https://brew.sh
7282
*/
73-
export function getBrewBinDir() {
83+
export function getBrewDir() {
7484
if (process.platform === "darwin") {
7585
if (process.arch === "arm64") {
76-
return "/opt/homebrew/bin/"
86+
return "/opt/homebrew"
7787
} else {
78-
return "/usr/local/bin/"
88+
return "/usr/local"
7989
}
8090
}
8191

8292
if (process.platform === "linux") {
83-
return "/home/linuxbrew/.linuxbrew/bin/"
93+
return "/home/linuxbrew/.linuxbrew"
8494
}
8595

8696
throw new Error("Unsupported platform for brew")

src/make/make.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { join } from "path"
12
import { addPath } from "envosman"
23
import { installAptPack } from "setup-apt"
3-
import { installBrewPack } from "setup-brew"
4+
import { getBrewDir, installBrewPack } from "setup-brew"
45
import { rcOptions } from "../cli-options.js"
56
import { hasDnf } from "../utils/env/hasDnf.js"
67
import { isArch } from "../utils/env/isArch.js"
@@ -17,8 +18,10 @@ export async function setupMake(version: string, _setupDir: string, _arch: strin
1718
}
1819
case "darwin": {
1920
await installBrewPack("make", version)
20-
await addPath("/usr/local/opt/make/libexec/gnubin", rcOptions)
21-
return { binDir: "/usr/local/opt/make/libexec/gnubin" }
21+
22+
const gnuBinDir = join(getBrewDir(), "opt/make/libexec/gnubin")
23+
await addPath(gnuBinDir, rcOptions)
24+
return { binDir: gnuBinDir }
2225
}
2326
case "linux": {
2427
if (isArch()) {

0 commit comments

Comments
 (0)