golangci-lint-action: "File exists" errors when un-taring golangci-lint

Follow-up to https://github.com/golangci/golangci-lint-action/issues/135, https://github.com/golangci/golangci-lint-action/pull/156 and #221.

Using v2, I’m still seeing these errors:

- name: Lint
  uses: golangci/golangci-lint-action@v2
  with:
    version: v1.37

Example is in https://github.com/andig/evcc/pull/1075/checks?check_run_id=2655591730

Apart from fixing using tar- why not just use go install instead?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 12
  • Comments: 39 (15 by maintainers)

Commits related to this issue

Most upvoted comments

@maintainers could we please reopen? IMHO we have the bad choices of slow CI due to excessive logging or slow CI due do omitting the caches, both are not good options.

This pops up (again?) in v3

      - name: Install Go
        uses: actions/setup-go@v3
        with:
          go-version: '1.18'
          cache: true

      - name: Build
        run: go build ./...

      - name: Lint
        uses: golangci/golangci-lint-action@v3
        with:
          version: v1.46.2
  Error: /usr/bin/tar: ../../../go/pkg/mod/golang.org/x/text@v0.3.7/message/catalog_test.go: Cannot open: File exists
  /usr/bin/tar: ../../../go/pkg/mod/golang.org/x/text@v0.3.7/README.md: Cannot open: File exists
  /usr/bin/tar: Exiting with failure status due to previous errors
  Warning: Tar failed with error: The process '/usr/bin/tar' failed with exit code 2

Can confirm, I’ve got the same issue: Error: /usr/bin/tar: ../../../../home/runner/go/pkg/mod/github.com/google/renameio@v1.0.1/doc.go: Cannot open: File exists Error: /usr/bin/tar: ../../../../home/runner/go/pkg/mod/github.com/google/renameio@v1.0.1/example_test.go: Cannot open: File exists

We cannot do anything within golangci-lint-action, since the @action/cache lib is maintained by GitHub. As I can see the extractTar function is imported from internal package: https://github.com/actions/toolkit/blob/main/packages/cache/src/cache.ts#L5 and the internal implementation does not contain --overwrite flag: https://github.com/actions/toolkit/blob/fcb8c4ca798bd0d81a9b07e2f7dffee8397c4707/packages/cache/src/internal/tar.ts#L57-L86

so there is no way to fix the issue within this action, while GitHub Action uses tar without --overwrite flag.

I would still recommend to disable the golangci-lint’s cache in case of using your own cache step:

skip-pkg-cache: true
skip-build-cache: true

and increase timeout

args: --timeout=10m

this action creates a cache for 3 folders:

  1. ~/.cache/go-build, can be disabled by setting skip-build-cache to true
  2. ~/go/pkg, can be disable by setting skip-pkg-cache to true
  3. .cache/golangci-lint, cannot be disable, it is the internal cache

As a “very hot” solution I have just disabled package caching:

skip-pkg-cache: true

This pops up (again?) in v3

      - name: Install Go
        uses: actions/setup-go@v3
        with:
          go-version: '1.18'
          cache: true

      - name: Build
        run: go build ./...

      - name: Lint
        uses: golangci/golangci-lint-action@v3
        with:
          version: v1.46.2
  Error: /usr/bin/tar: ../../../go/pkg/mod/golang.org/x/text@v0.3.7/message/catalog_test.go: Cannot open: File exists
  /usr/bin/tar: ../../../go/pkg/mod/golang.org/x/text@v0.3.7/README.md: Cannot open: File exists
  /usr/bin/tar: Exiting with failure status due to previous errors
  Warning: Tar failed with error: The process '/usr/bin/tar' failed with exit code 2

@StevenACoffman I’ve just upgraded to 3.0 and I’m still seeing this in https://github.com/evcc-io/evcc/runs/5343866024?check_suite_focus=true:

Run golangci/golangci-lint-action@v3
[10](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:10)
prepare environment
[11](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:11)
  Finding needed golangci-lint version...
[12](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:12)
  Requested golangci-lint 'latest', using 'v1.44.2', calculation took [13](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:13)5ms
13
  Installing golangci-lint v1.44.2...
[14](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:14)
  Downloading https://github.com/golangci/golangci-lint/releases/download/v1.44.2/golangci-lint-1.44.2-linux-amd64.tar.gz ...
[15](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:15)
  /usr/bin/tar xz --overwrite --warning=no-unknown-keyword --overwrite -C /home/runner -f /home/runner/work/_temp/c6bcc178-2c51-4379-b906-43113d6e[16](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:16)f6
16
  Installed golangci-lint into /home/runner/golangci-lint-1.44.2-linux-amd64/golangci-lint in 531ms
[17](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:17)
  Received 83886080 of 408206632 (20.5%), 79.9 MBs/sec
[18](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:18)
  Received 230686720 of 408206632 (56.5%), 109.8 MBs/sec
[19](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:19)
  Received 373293056 of 408[20](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:20)6632 (91.4%), 118.5 MBs/sec
20
  Received 408206632 of 408206632 (100.0%), 113.1 MBs/sec
[21](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:21)
  Cache Size: ~389 MB (408206632 B)
[22](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:22)
  /usr/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/45a7e3c2-b450-405d-b8d9-022c29095af0/cache.tzst -P -C /home/runner/work/evcc/evcc
[23](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:23)
  Error: /usr/bin/tar: ../../../go/pkg/mod/go.uber.org/goleak@v1.1.10/signal_test.go: Cannot open: File exists
[24](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:24)
  /usr/bin/tar: ../../../go/pkg/mod/go.uber.org/goleak@v1.1.10/go.sum: Cannot open: File exists
[25](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:25)
  /usr/bin/tar: ../../../go/pkg/mod/go.uber.org/goleak@v1.1.10/LICENSE: Cannot open: File exists
[26](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:26)
  /usr/bin/tar: ../../../go/pkg/mod/go.uber.org/goleak@v1.1.10/.travis.yml: Cannot open: File exists
[27](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:27)
  Error: /usr/bin/tar: ../../../go/pkg/mod/go.uber.org/goleak@v1.1.10/leaks_test.go: Cannot open: File exists
[28](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:28)
  Error: /usr/bin/tar: ../../../go/pkg/mod/go.uber.org/goleak@v1.1.10/tools.go: Cannot open: File exists
[29](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:29)
  Error: /usr/bin/tar: ../../../go/pkg/mod/go.uber.org/goleak@v1.1.10/testmain_test.go: Cannot open: File exists
[30](https://github.com/evcc-io/evcc/runs/5343897218?check_suite_focus=true#step:11:30)
  Error: /usr/bin/tar: ../../../go/pkg/mod/go.uber.org/goleak@v1.1.10/leaks.go: Cannot open: File exists

Can you please reopen?

Oh, I just noticed that this action runs actions/setup-go itself. I was taking care of that myself before running this action, because I need to run go list first as explained earlier.

Is it possible to influence which version of Go this action installs? I don’t see mention of such a parameter in the action.yaml file.

and disable action caching:

Is that still the suggested workaround? Imho, without adding it I’m back to the errors (and apparently slow linting times due to excessive logging) while with adding I’m slow due to the missing lint caches.

actions/cache has been updated. https://github.com/golangci/golangci-lint-action/commit/4ef1b2ec49b85244db5924ab1ba5ee23540201fe

Will the v2.5.3 release fix this issue?

Looks like someone tried to fix this upstream for this very package here: https://github.com/actions/toolkit/pull/717 but that PR was superseded by https://github.com/actions/toolkit/pull/807 which was merged on May 21, 2021.

However, the last release of @actions/cache was 1.0.7 which was Tuesday, April 13, 2021, prior to the merge of the fix. 😞

As a result, this will not be fixed until a new upstream release is cut and this updates to use it, but no other code needs to be changed.