Skip to content

Commit

Permalink
Set GOTMPDIR to a child directory (#4183)
Browse files Browse the repository at this point in the history
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.
```
  • Loading branch information
rdner authored Feb 2, 2024
1 parent 84e6bc1 commit 2555088
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .buildkite/hooks/pre-command.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2555088

Please sign in to comment.