GitHubActions Runner Error: Command failed: go env GOPATH

Viewed 32

We have GitHubActions and we run it in an Centos Server. We have set the root's .bashrc as export GOROOT=/opt/go export PATH=$PATH:$GOROOT/bin In the Github Actions we have the file:

    setup:
    needs: cleanup
    name: Setup
    runs-on: [self-hosted, Linux, X64, CentOS-Linux-7.9]
    services:
      postgres:
        image: postgres:latest
   - name: Set up Go 1.17
        uses: actions/setup-go@v2
        with:
         go-version: 1.17
    #      id: Go
      - run: go version
        
       
      - name: Checkout code into go module directory
        uses: actions/checkout@v2

When Github Actions runs this , it throws the error:

0s
Run actions/setup-go@v2
  with:
    go-version: 1.17
    stable: true
    token: ***
 ...
Setup go stable version spec 1.17
Found in cache @ /opt/actions-runner/_work/_tool/go/1.17.11/x64
Added go to the path
missing $GOPATH
Error: Command failed: go env GOPATH
missing $GOPATH

Can someone please help with this error?
The Go installation is working and on the Linux box as root 'go version' works.

1 Answers

That looks like actions/setup-go issue 116 which includes:

I believe the reason of issue is missing $HOME variable on the self-hosted runners.

The missing HOME variable makes it so that Go is not able to make default folders for GOPATH and GOCACHE and such.

So double-check what echo $HOME displays in your runner.


The OP AwsGeek confirms in the comments:

First as suggested I did an echo $HOME and it was empty and under the env: I added the value for home env: HOME: "/home/xxxx-account"

Related