golangci-lint-action: [Error] Can't run linter goanalysis_metalinter: buildir

I found error suddenly due to go1.18 issue Then I tried to change configuration followed by the above issue, another error as title happened after configuration changed.

Errors are

run golangci-lint
  Running [/home/runner/golangci-lint-1.45.2-linux-amd64/golangci-lint run --out-format=github-actions --path-prefix=cmds/alpha] in [/home/runner/work/org/my-repo/cmds/alpha] ...
  level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package : could not load export data: no export data for \"io/fs\""
  level=error msg="Running error: 1 error occurred:\n\t* can't run linter goanalysis_metalinter: buildir: failed to load package : could not load export data: no export data for \"io/fs\"\n\n"

configuration

  golangci:
    name: lint
    runs-on: ubuntu-latest
    strategy:
      matrix:
        go-version: [1.17]
    steps:
      - uses: actions/setup-go@v3
        with:
          go-version: ${{ matrix.go }}
      - uses: actions/checkout@v3
      - name: golangci-lint for alpha cmds
        uses: golangci/golangci-lint-action@v3
        with:
          version: v1.45.2
          working-directory: cmds/alpha

difference from most of common use is I’m using monorepo and I use working-directory. I’m not sure .golangcli.yaml stored in root directory is used properly in this version, thought it used to be work.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (1 by maintainers)

Most upvoted comments

getting this issue as well both locally and in ci workflow

WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package decoder: could not load export data: no export data for "github.com/kolesa-team/go-webp/decoder" 
ERRO Running error: 1 error occurred:
	* can't run linter goanalysis_metalinter: buildir: failed to load package decoder: could not load export data: no export data for "github.com/kolesa-team/go-webp/decoder"
 
make: *** [ci-lint] Error 3

Fwiw, in my case, the same issue was caused by depending on a private repository and solved by following the steps here: https://blog.fabianmendez.dev/how-to-use-private-go-module-in-github-actions

For me it was malformed go dependencies made it tidy: go mod tidy

Ive just noticed this happening to me both on ci and locally.

> golangci-lint version
golangci-lint has version 1.51.0 built from 6d3f06c5 on 2023-02-02T08:24:52Z

Was running fine on v1.50

getting this issue as well both locally and in ci workflow

WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package decoder: could not load export data: no export data for "github.com/kolesa-team/go-webp/decoder" 
ERRO Running error: 1 error occurred:
	* can't run linter goanalysis_metalinter: buildir: failed to load package decoder: could not load export data: no export data for "github.com/kolesa-team/go-webp/decoder"
 
make: *** [ci-lint] Error 3

i believe in your case go-webp is dependent on some third party binary that is not by default installed on local machine nor the gb action runner. As their github page states: (https://github.com/kolesa-team/go-webp)

Requirements - libwebp

You have to add preliminary step in you action that will install this dependency before running lint. Go needs to be able to compile your code and it needs all dependencies to do so.

Upgrading the golangci-lint version fixed the problem for me.

brew upgrade golangci-lint

my golangci-lint version was 1.50.1 and my go version was: go version go1.18.1 darwin/arm64

not effect

I also faced this issue with this workflow.

This is a basic workflow to help you get started with Actions

name: Linting and Static Code Analysis

on: [push, pull_request]

jobs: golangci: name: lint

strategy:
  matrix:
    go-version: [1.18.x]
    platform: [self-hosted]

runs-on: ubuntu-latest
steps:
  - name: Setup Go
    uses: actions/setup-go@v3
    with:
      go-version: ${{ matrix.go-version }}

  - name: Checkout Repo
    uses: actions/checkout@v3

  - name: golangci-lint
    uses: golangci/golangci-lint-action@v3
    with:
      # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
      version: v1.29

Later I updated the golangci-lint version to v1.46.2 (latest one)

And it worked. I guess this issue can be resolved.