Skip to content

Commit d35f678

Browse files
authored
Merge pull request #57 from aminya/vcpkg [skip ci]
2 parents 9b3e93e + 7949188 commit d35f678

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

dist/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/vcpkg/vcpkg.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import execa from "execa"
33
import { existsSync } from "fs"
44
import { dirname, join } from "path"
55
import which from "which"
6+
import { isRoot } from "../utils/env/sudo"
7+
import { execSudo } from "../utils/exec/sudo"
68
import { addShellExtension, addShellHere } from "../utils/extension/extension"
79
import { setupAptPack } from "../utils/setup/setupAptPack"
810
import { InstallationInfo } from "../utils/setup/setupBin"
@@ -29,6 +31,16 @@ export async function setupVcpkg(_version: string, setupDir: string, _arch: stri
2931
}
3032

3133
execa.sync(addShellExtension(addShellHere("bootstrap-vcpkg")), { cwd: setupDir, shell: true, stdio: "inherit" })
34+
35+
// change the owner to the SUDO_USER in setupDir. vcpkg requires this so it can install things without sudo
36+
if (
37+
(process.platform === "linux" || process.platform === "darwin") &&
38+
isRoot() &&
39+
process.env.SUDO_USER !== undefined
40+
) {
41+
await execSudo("chown", ["-R", process.env.SUDO_USER, setupDir], setupDir)
42+
}
43+
3244
addPath(setupDir)
3345
// eslint-disable-next-line require-atomic-updates
3446
hasVCPKG = true

0 commit comments

Comments
 (0)