Skip to content

Commit 1042fff

Browse files
committed
fix: unset Path, TMP, and TEMP before MSVC installations
1 parent 3b5817d commit 1042fff

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
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.

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/msvc/msvc.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export async function setupMSVC(
2222

2323
let toolset: string | undefined
2424
let VCTargetsPath: string | undefined
25-
// TODO enable this code path once its bugs are fixed
2625
// https://github.com/aminya/setup-cpp/issues/1
2726
try {
2827
if (version === "14.0") {
@@ -41,13 +40,7 @@ export async function setupMSVC(
4140
error(`The given MSVC versions ${versionGiven} is not supported yet.`)
4241
}
4342
} catch (e) {
44-
if (
45-
!(e as string | Error)
46-
.toString()
47-
.includes("Item has already been added. Key in dictionary: 'Path' Key being added: 'PATH'")
48-
) {
49-
error(e as string | Error)
50-
}
43+
error(e as string | Error)
5144
}
5245
// run vcvarsall.bat environment variables
5346
setupVCVarsall(version, VCTargetsPath, arch, toolset, sdk, uwp, spectre)

src/utils/setup/setupChocoPack.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@ export async function setupChocoPack(name: string, version?: string, args: strin
1414
hasChoco = true
1515
}
1616

17+
// https://github.com/jberezanski/ChocolateyPackages/issues/97#issuecomment-986825694
18+
const PATH = process.env.PATH
19+
const env = { ...process.env }
20+
delete env.TMP
21+
delete env.TEMP
22+
delete env.Path
23+
env.PATH = PATH
24+
1725
if (version !== undefined && version !== "") {
18-
execa.sync("choco", ["install", "-y", name, `--version=${version}`, ...args])
26+
execa.sync("choco", ["install", "-y", name, `--version=${version}`, ...args], { env, extendEnv: false })
1927
} else {
20-
execa.sync("choco", ["install", "-y", name, ...args])
28+
execa.sync("choco", ["install", "-y", name, ...args], { env, extendEnv: false })
2129
}
2230

2331
const binDir = "C:/ProgramData/Chocolatey/bin/"

0 commit comments

Comments
 (0)