Error attempting to run Go build in Windows

Hello,

Since around early September 2024, I’ve had an issue with builds of a Go language project on Windows. Windows builds for the project were working well for years before. The Windows build fails even when no code changes are made when compared to a previously passing build.

The builds fail with an error during the travis_setup_go step, and time out. The line erroring is an export of the PATH variable:

The command "export PATH=/bin:/c/Users/travis/gopath/bin:/c/Users/travis/bin:/bin:/usr/bin:/c/tools/ruby27/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/ProgramData/GooGet:/c/Program Files/Google/Compute Engine/metadata_scripts:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/Program Files/Google/Compute Engine/sysprep:/c/Program Files/Docker:/c/ProgramData/chocolatey/bin:/c/Program Files/CMake/bin:/c/Program Files/Git/cmd:/c/Program Files/LLVM/bin:/c/Program Files/dotnet:/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:/c/tools/BCURRAN3:/c/Users/travis/AppData/Local/Microsoft/WindowsApps:/c/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin" failed and exited with 1 during .

For the Travis CI team, here is an example of a passing build:

And here are examples of failing builds:

Have you encountered this problem before? Does the Travis CI team have any insight into what the problem is?

Hi @tedw,

Have you tried using a clean path in your `.travis.yml? For example:

 before_script:
  - export PATH=$PATH:/usr/local/go/bin

Let me know if this works.

Have you tried using a clean path in your `.travis.yml?

Thanks for the suggestion @Montana. I tried adding “/usr/local/go/bin” to the path as you recommended, but it seems I’m still getting the same error.

My build runs the go tool in before_install. First I added the line to before_install:

 before_install:
+  - export PATH="${PATH}:/usr/local/go/bin"
   [...]

then I moved it to env:

 env:
   global:
     [...]
+    - export PATH="${PATH}:/usr/local/go/bin"

but the error appears to be the same as the one in my original post in all cases.

Here are a few failing builds with the PATH change:

Build log:

$ export PATH="${PATH}:/usr/local/go/bin"

$ travis_setup_go
$ export GOPATH="/c/Users/travis/gopath"
$ export PATH="/c/Users/travis/gopath/bin:/c/Users/travis/bin:/bin:/usr/bin:/c/tools/ruby27/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/ProgramData/GooGet:/c/Program Files/Google/Compute Engine/metadata_scripts:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/Program Files/Google/Compute Engine/sysprep:/c/Program Files/Docker:/c/ProgramData/chocolatey/bin:/c/Program Files/CMake/bin:/c/Program Files/Git/cmd:/c/Program Files/LLVM/bin:/c/Program Files/dotnet:/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:/c/tools/BCURRAN3:/c/Users/travis/AppData/Local/Microsoft/WindowsApps:/c/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin:/usr/local/go/bin"
$ export GO111MODULE="auto"
$ export GOROOT=
$ export PATH=/bin:/c/Users/travis/gopath/bin:/c/Users/travis/bin:/bin:/usr/bin:/c/tools/ruby27/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/ProgramData/GooGet:/c/Program Files/Google/Compute Engine/metadata_scripts:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/Program Files/Google/Compute Engine/sysprep:/c/Program Files/Docker:/c/ProgramData/chocolatey/bin:/c/Program Files/CMake/bin:/c/Program Files/Git/cmd:/c/Program Files/LLVM/bin:/c/Program Files/dotnet:/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:/c/tools/BCURRAN3:/c/Users/travis/AppData/Local/Microsoft/WindowsApps:/c/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin:/usr/local/go/bin
The command "export PATH=/bin:/c/Users/travis/gopath/bin:/c/Users/travis/bin:/bin:/usr/bin:/c/tools/ruby27/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/ProgramData/GooGet:/c/Program Files/Google/Compute Engine/metadata_scripts:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/Program Files/Google/Compute Engine/sysprep:/c/Program Files/Docker:/c/ProgramData/chocolatey/bin:/c/Program Files/CMake/bin:/c/Program Files/Git/cmd:/c/Program Files/LLVM/bin:/c/Program Files/dotnet:/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:/c/tools/BCURRAN3:/c/Users/travis/AppData/Local/Microsoft/WindowsApps:/c/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin:/usr/local/go/bin" failed and exited with 1 during .

Your build has been stopped.

Hi @tedw,

Try something like this:

os: windows  
language: go

go:
  - "1.20"  # or whatever version you need

before_install:
  - go version || echo "Go is not installed"
  - choco install golang -y  # Ensures Go is installed on Windows
  - export PATH="/c/Go/bin:$PATH"
  - export GOPATH="/c/Users/travis/gopath"
  - echo "GOPATH: $GOPATH"
  - echo "PATH: $PATH"
  - go version

install:
  - go mod tidy  
script:
  - go build ./...
  - go test ./...