From 255508819ee5f6f0a8665f918862d365ff1c2e65 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 2 Feb 2024 14:57:21 +0000 Subject: [PATCH] Set GOTMPDIR to a child directory (#4183) So, Windows does not detect temporary Go binaries (e.g. magefile) as a virus. This solves: ``` failed to run compiled magefile: fork/exec C:\Users\windows\magefile\6e561802bbe21387b05a72ec1f51afbf0b1d8e8d.exe: Operation did not complete successfully because the file contains a virus or potentially unwanted software. ``` --- .buildkite/hooks/pre-command.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.buildkite/hooks/pre-command.ps1 b/.buildkite/hooks/pre-command.ps1 index ca5b34bc920..44a595dd918 100644 --- a/.buildkite/hooks/pre-command.ps1 +++ b/.buildkite/hooks/pre-command.ps1 @@ -14,8 +14,12 @@ go version $GOPATH = $(go env GOPATH) $env:Path = "$GOPATH\bin;" + $env:Path +$env:GOTMPDIR = "$GOPATH\tmp" +New-Item -ItemType Directory -Force -Path $env:GOTMPDIR [Environment]::SetEnvironmentVariable("GOPATH", "$GOPATH", [EnvironmentVariableTarget]::Machine) +[Environment]::SetEnvironmentVariable("GOTMPDIR", "$GOPATH\tmp", [EnvironmentVariableTarget]::Machine) [Environment]::SetEnvironmentVariable("Path", "$GOPATH\bin;$env:Path", [EnvironmentVariableTarget]::Machine) +go env # Install tools go install github.com/magefile/mage