Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64 #13

Closed
pashagolub opened this issue May 18, 2022 · 9 comments
Closed

Comments

@pashagolub
Copy link

One of the latest runs of my workflow failed:

Run jandelgado/gcov2lcov-action@master
  with:
    infile: profile.cov
    outfile: coverage.lcov
    version: latest
Run set -x && curl -sLf "$([ latest == latest ] && echo $LATEST_RELEASE || echo $RELEASE)/${NAME}.tar.gz" | tar zxf - --strip 1
  set -x && curl -sLf "$([ latest == latest ] && echo $LATEST_RELEASE || echo $RELEASE)/${NAME}.tar.gz" | tar zxf - --strip 1
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    NAME: gcov2lcov-linux-amd64
    RELEASE: https://github.com/jandelgado/gcov2lcov/releases/download/latest
    LATEST_RELEASE: https://github.com/jandelgado/gcov2lcov/releases/latest/download
+ tar zxf - --strip 1
++ '[' latest == latest ']'
++ echo https://github.com/jandelgado/gcov2lcov/releases/latest/download
+ curl -sLf https://github.com/jandelgado/gcov2lcov/releases/latest/download/gcov2lcov-linux-amd64.tar.gz
Run set -x && /tmp/gcov2lcov-linux-amd64 -infile "profile.cov" -outfile "coverage.lcov"
  set -x && /tmp/gcov2lcov-linux-amd64 -infile "profile.cov" -outfile "coverage.lcov"
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
+ /tmp/gcov2lcov-linux-amd64 -infile profile.cov -outfile coverage.lcov
2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64
...

Is it because runner doesn't have Go v1.13 installed anymore?

@omegion
Copy link

omegion commented May 20, 2022

Same here, it fails for me too.

@omegion
Copy link

omegion commented May 20, 2022

You can try https://github.com/mattn/goveralls#github-actions. @pashagolub

@pashagolub
Copy link
Author

I did thanks

@jandelgado
Copy link
Owner

Good question ;) I'll check it in the next days

@jandelgado
Copy link
Owner

@pashagolub I can't find where this reference to go 1.13 is coming from. Any ideas?

@pashagolub
Copy link
Author

Sorry. No idea. But my other projects suffers from the very same error: https://github.com/cybertec-postgresql/pg_timetable/runs/6518909375

@dragondgold
Copy link

In my case I solved it by adding this as a step before gcov2lcov:

- name: Set up GOPATH
  shell: bash
  run: |
     echo "GOROOT=$(go env GOROOT)" >> "$GITHUB_ENV"

@jandelgado
Copy link
Owner

jandelgado commented May 23, 2022

I was able to reproduce the problem as follows:

  1. check out source repo
  2. run go mod download
  3. run tests with go test -v -coverprofile=profile.cov
  4. unset GOROOT environment variable (unset GOROOT)
  5. run gcov2lcov-linux-amd64 -infile profile.cov -outfile profile.lcov

This results in warnings like:

022/05/23 16:00:58 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

However, if GOROOT is set properly, everything works fine. The reason that GOROOT is no longer set is because of a change in the setup-go action, which was recently introduced. I'll see how I can fix it...

jandelgado added a commit that referenced this issue May 23, 2022
because the invoked gcov2lcov uses golang API functions that rely on
GOROOT (i.e. build.Import, which calls
https://cs.opensource.google/go/go/+/refs/tags/go1.18.2:src/go/build/build.go;drc=0a1a092c4b56a1d4033372fbd07924dad8cbb50b;l=544)

Up to version v3 of the github setup-go action, the GOROOT variable was
automatically set. But that changed with v3 of the setup-go action, and
that's why we now set GOROOT.
@jandelgado jandelgado reopened this May 23, 2022
@jandelgado
Copy link
Owner

@pashagolub I fixed the problem by always setting GOROOT before calling gcov2lcov and released a new version.
Just use the v1 tag like in jandelgado/gcov2lcov-action@v1 to use the up-to-date version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants