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

"no export data for" error since v1.44 #3376

Closed
4 tasks done
albertteoh opened this issue Nov 25, 2022 · 5 comments
Closed
4 tasks done

"no export data for" error since v1.44 #3376

albertteoh opened this issue Nov 25, 2022 · 5 comments
Labels
area: cgo Related to CGO question Further information is requested

Comments

@albertteoh
Copy link

albertteoh commented Nov 25, 2022

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc.).
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)

Description of the problem

Running the linter returns the following error:

WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package proj: could not load export data: no export data for "github.com/pebbe/go-proj-4/proj"
ERRO Running error: 1 error occurred:
	* can't run linter goanalysis_metalinter: buildir: failed to load package proj: could not load export data: no export data for "github.com/pebbe/go-proj-4/proj"

After a bit of debugging, I found returning nil appears to prevent the error, but may just be a hack that hides a deeper problem, which I think is around understanding why github.com/pebbe/go-proj-4/proj doesn't have an exportFile.

I'd be appreciative if someone could explain how exportFiles are generated and why it's missing for github.com/pebbe/go-proj-4/proj; or, if this is "expected", whether if my proposed change is an appropriate fix: https://github.com/golangci/golangci-lint/compare/master...albertteoh:golangci-lint:warn-instead-of-err-no-exportfile?expand=1.

Worth noting that I do not see this error when running with the docker image: golangci/golangci-lint:v1.43-alpine
... and this error starts appearing from golangci/golangci-lint:v1.44-alpine.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.50.1 built from 8926a95f on 2022-10-22T10:50:47Z

Configuration file

$ cat .golangci.yml
run:
  timeout: 5m
  modules-download-mode: vendor
  go: "1.19"

issues:
  exclude-rules:
    - path: '(.+)_test\.go'
      linters:
        - gosec

linter-settings:
  depguard:
    list-type: blacklist
    include-go-root: true
    packages:
      - io/ioutil
    packages-with-error-message:
      - io/ioutil: "Use os or io instead of io/ioutil"
  goimports:
    local-prefixes: github.com/nearmap/openworld
  gosimple:
    go: "1.19"
    checks: ["all"]

linters:
  fast: false
  enable:
    - depguard
    - gofmt
    - gofumpt
    - goimports
    - gosec
    - govet
    - misspell

Go environment

$ go version && go env
go version go1.19.1 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/vagrant/.cache/go-build"
GOENV="/home/vagrant/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/vagrant/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/vagrant/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/vagrant/go/src/github.com/nearmap/openworld/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2885735728=/tmp/go-build -gno-record-gcc-switches"```

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /vagrant/go/src/github.com/nearmap/openworld /vagrant/go/src/github.com/nearmap /vagrant/go/src/github.com /vagrant/go/src /vagrant/go /vagrant / /home/vagrant]
INFO [config_reader] Used config file .golangci.yaml
INFO [lintersdb] Active 13 linters: [depguard errcheck gofmt gofumpt goimports gosec gosimple govet ineffassign misspell staticcheck typecheck unused]
INFO [loader] Go packages loading at mode 575 (compiled_files|exports_file|files|imports|deps|name|types_sizes) took 17.15944041s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 134.341821ms
INFO [linters_context/goanalysis] analyzers took 1m15.456566948s with top 10 stages: buildir: 44.298340449s, gofumpt: 4.425482723s, goimports: 4.386180343s, gofmt: 4.236456711s, misspell: 4.019975918s, isgenerated: 3.115835806s, inspect: 1.612242537s, gosec: 1.222692737s, ctrlflow: 915.632099ms, printf: 880.704774ms
WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package proj: could not load export data: no export data for "github.com/pebbe/go-proj-4/proj"
INFO [runner] processing took 2.378µs with stages: max_same_issues: 450ns, max_from_linter: 298ns, nolint: 273ns, skip_dirs: 242ns, cgo: 112ns, filename_unadjuster: 102ns, skip_files: 101ns, uniq_by_line: 99ns, path_prettifier: 99ns, autogenerated_exclude: 97ns, severity-rules: 95ns, exclude: 92ns, max_per_file_from_linter: 44ns, diff: 44ns, sort_results: 43ns, exclude-rules: 40ns, identifier_marker: 38ns, path_shortener: 38ns, source_code: 37ns, path_prefixer: 34ns
INFO [runner] linters took 19.846467904s with stages: goanalysis_metalinter: 19.846438948s
ERRO Running error: 1 error occurred:
	* can't run linter goanalysis_metalinter: buildir: failed to load package proj: could not load export data: no export data for "github.com/pebbe/go-proj-4/proj"

INFO Memory: 370 samples, avg is 361.5MB, max is 1005.1MB
INFO Execution took 37.153737047s```

Code example or link to a public repository

This affects a private repository. However, the dependency that seems to be the cause of this error is: github.com/pebbe/go-proj-4/proj

// add your code here
@albertteoh albertteoh added the bug Something isn't working label Nov 25, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Nov 25, 2022

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ldez
Copy link
Member

ldez commented Nov 25, 2022

Hello,

can you provide a reproducible example?

@ldez ldez added the feedback required Requires additional feedback label Nov 25, 2022
@albertteoh
Copy link
Author

Hello,

can you provide a reproducible example?

Thanks for the speedy response @ldez!

Sure, here's a reproducible example: https://github.com/albertteoh/repro-exportfile-missing

@ldez ldez removed the feedback required Requires additional feedback label Nov 25, 2022
@ldez
Copy link
Member

ldez commented Nov 25, 2022

I think it's problem related to CGO:

$ go run .            
# github.com/pebbe/go-proj-4/proj
In file included from ../../go/pkg/mod/github.com/pebbe/go-proj-4@v5.0.0+incompatible/proj/proj.go:33:
./proj.h:2:10: fatal error: proj_api.h: No such file or directory
    2 | #include <proj_api.h>
      |          ^~~~~~~~~~~~
compilation terminated.

@ldez ldez added question Further information is requested area: cgo Related to CGO and removed bug Something isn't working labels Nov 25, 2022
@albertteoh
Copy link
Author

I think it's problem related to CGO:

Yup, I think you're right.

  • The reason why upgrading from v1.43 -> v1.44.0 breaks for us is because linter warnings are (correctly) surfaced as errors, I think from this PR: Return error if any linter fails to run #2471.
  • I think the mistake I'm making is to run the golangci/golangci-lint:v1.44-alpine image against our source code (via volume mount) without successfully installing the C Proj library within the new image layer, which prevents the GC compiler from producing the export file.
  • To prove this, I installed golangci-lint v1.50.1 in the "reproducer" repo (albertteoh/repro-exportfile-missing@2862d3a) and running make run succeeds without error 🥳 .

Thanks for your help @ldez!

I'm closing this issue for now and will apply my learnings to our CI pipeline.

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

No branches or pull requests

2 participants