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] Can't run linter goanalysis_metalinter: buildir #448

Closed
hiromaily opened this issue Apr 11, 2022 · 22 comments
Closed

[Error] Can't run linter goanalysis_metalinter: buildir #448

hiromaily opened this issue Apr 11, 2022 · 22 comments
Labels
question Further information is requested

Comments

@hiromaily
Copy link

hiromaily commented Apr 11, 2022

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.

@GGXXLL
Copy link

GGXXLL commented Apr 15, 2022

Same issue. Action Log.
But it is normal locally.

@hiromaily
Copy link
Author

the cause was found by his comment :)

@hexcowboy
Copy link

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

@vaclav-dvorak
Copy link

In theory this can be tied with this: golangci/golangci-lint#827

specifically with this comment:
golangci/golangci-lint#827 (comment)

@ashutoshsinghparmar
Copy link

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.

@vaclav-dvorak
Copy link

vaclav-dvorak commented Jul 7, 2022

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.

@cgyFight
Copy link

cgyFight commented Dec 2, 2022

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

not effect

@mariomac
Copy link

I got this problem and the issue was a compiler error in one of my vendored dependencies. Once I updated them to fix the error, this error disappeared.

@ldez ldez added the question Further information is requested label Dec 14, 2022
@itsNotMyUsername
Copy link

itsNotMyUsername commented Feb 2, 2023

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

@osery
Copy link

osery commented Feb 5, 2023

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

@yuseferi
Copy link

I have this problem with an external package,

goanalysis_metalinter: buildir: failed to load package zetasql

@KaymeKaydex
Copy link

I have the same problem with go-pdfium package

golang-ci version is 1.52.2

    * can't run linter goanalysis_metalinter: buildir: failed to load package implementation_cgo: could not load export data: no export data for "github.com/klippa-app/go-pdfium/internal/implementation_cgo"

@ElanHasson
Copy link

Same in 1.54.2.

can't run linter goanalysis_metalinter: buildir: failed to load package yqlib: could not load export data: no export data for "github.com/mikefarah/yq/v4/pkg/yqlib"

@ldez
Copy link
Member

ldez commented Aug 23, 2023

All errors related to buildir are compilation errors.

Why do you have buildir errors?

  • Ensure the version of golangci-lint is built with a compatible version of Go.
  • Ensure dependencies are up-to-date with go mod tidy.
  • Ensure building works with go run ./.../go build ./... - whole package.
  • If using CGO, ensure all required system libraries are installed.

@KaymeKaydex

This comment was marked as off-topic.

@shsma
Copy link

shsma commented Oct 12, 2023

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

brew upgrade golangci-lint

@KaymeKaydex
Copy link

I have the same problem with go-pdfium package

golang-ci version is 1.52.2

    * can't run linter goanalysis_metalinter: buildir: failed to load package implementation_cgo: could not load export data: no export data for "github.com/klippa-app/go-pdfium/internal/implementation_cgo"

so, my problem was solved when i installed .so files

@nishant2192
Copy link

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

@oyyblin
Copy link

oyyblin commented Feb 7, 2024

deleted go.mod and re-run go mod init fixed for me

@vianuevm
Copy link

vianuevm commented Apr 2, 2024

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

I appreciate your comment here, this is the same problem I had. Thanks!

@jdemeyer
Copy link

Ensure dependencies are up-to-date with go mod tidy.

Came here to say that this solved a similar problem for me

@Hundao
Copy link

Hundao commented Jul 5, 2024

deleted go.mod and re-run go mod init fixed for me

This way works for me, thanks.

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

No branches or pull requests