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

Unable to run golangci-lint in jenkins build #1219

Closed
3 tasks done
CSRaghunandan opened this issue Jul 8, 2020 · 5 comments
Closed
3 tasks done

Unable to run golangci-lint in jenkins build #1219

CSRaghunandan opened this issue Jul 8, 2020 · 5 comments
Labels
bug Something isn't working

Comments

@CSRaghunandan
Copy link

Thank you for creating the issue!

  • 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).

Please include the following information:

Version of golangci-lint
1.27
Config file
Using the default config.
Go environment
12:56:09 + go version
12:56:09 go version go1.14.4 linux/amd64
12:56:09 + go env
12:56:09 GO111MODULE=""
12:56:09 GOARCH="amd64"
12:56:09 GOBIN=""
12:56:09 GOCACHE="/var/jenkins_home/.cache/go-build"
12:56:09 GOENV="/var/jenkins_home/.config/go/env"
12:56:09 GOEXE=""
12:56:09 GOFLAGS=""
12:56:09 GOHOSTARCH="amd64"
12:56:09 GOHOSTOS="linux"
12:56:09 GOINSECURE=""
12:56:09 GONOPROXY=""
12:56:09 GONOSUMDB=""
12:56:09 GOOS="linux"
12:56:09 GOPATH="/var/jenkins_home/workspace/Auto-Quote-Builds/golang-backend-fabxprime"
12:56:09 GOPRIVATE=""
12:56:09 GOPROXY="https://proxy.golang.org,direct"
12:56:09 GOROOT="/var/jenkins_home/tools/org.jenkinsci.plugins.golang.GolangInstallation/Go_1.14.4_golang.org"
12:56:09 GOSUMDB="sum.golang.org"
12:56:09 GOTMPDIR=""
12:56:09 GOTOOLDIR="/var/jenkins_home/tools/org.jenkinsci.plugins.golang.GolangInstallation/Go_1.14.4_golang.org/pkg/tool/linux_amd64"
12:56:09 GCCGO="gccgo"
12:56:09 AR="ar"
12:56:09 CC="gcc"
12:56:09 CXX="g++"
12:56:09 CGO_ENABLED="1"
12:56:09 GOMOD="/var/jenkins_home/workspace/Auto-Quote-Builds/golang-backend-fabxprime/src/fabxprime/go.mod"
12:56:09 CGO_CFLAGS="-g -O2"
12:56:09 CGO_CPPFLAGS=""
12:56:09 CGO_CXXFLAGS="-g -O2"
12:56:09 CGO_FFLAGS="-g -O2"
12:56:09 CGO_LDFLAGS="-g -O2"
12:56:09 PKG_CONFIG="pkg-config"
12:56:09 GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build483847592=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running
12:59:54 level=info msg="[config_reader] Config search paths: [./ /var/jenkins_home/workspace/Auto-Quote-Builds/golang-backend-fabxprime/src /var/jenkins_home/workspace/Auto-Quote-Builds/golang-backend-fabxprime /var/jenkins_home/workspace/Auto-Quote-Builds /var/jenkins_home/workspace /var/jenkins_home /var /]"
12:59:54 level=info msg="[lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]"
12:59:54 level=info msg="[loader] Go packages loading at mode 575 (exports_file|files|types_sizes|compiled_files|deps|imports|name) took 115.918513ms"
12:59:54 level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 6.680432ms"

12:59:58 level=info msg="[linters context/goanalysis] analyzers took 4.951727904s with top 10 stages: buildir: 3.96913234s, inspect: 450.121678ms, fact_purity: 176.493431ms, ctrlflow: 150.991633ms, fact_deprecated: 99.68408ms, printf: 93.605028ms, S1031: 560.454µs, lostcancel: 177.128µs, ineffassign: 175.219µs, S1005: 168.752µs"
12:59:58 level=warning msg="[runner] Can't run linter goanalysis_metalinter: S1002: failed prerequisites: [(inspect@fabxprime/utils, isgenerated@fabxprime/utils): analysis skipped: errors in package: [/var/jenkins_home/workspace/Auto-Quote-Builds/golang-backend-fabxprime/src/fabxprime/utils/UploadFilesToAzure.go:12:2: could not import github.com/Azure/azure-storage-blob-go/azblob (/var/jenkins_home/workspace/Auto-Quote-Builds/golang-backend-fabxprime/src/fabxprime/vendor/github.com/Azure/azure-storage-blob-go/azblob/chunkwriting.go:13:8: could not import github.com/google/uuid (/var/jenkins_home/workspace/Auto-Quote-Builds/golang-backend-fabxprime/src/fabxprime/vendor/github.com/google/uuid/node_net.go:9:8: could not import net (/var/jenkins_home/tools/org.jenkinsci.plugins.golang.GolangInstallation/Go_1.14.4_golang.org/src/net/cgo_linux.go:12:8: could not import C (cgo preprocessing failed))))]]"
12:59:58 level=info msg="[linters context/goanalysis] analyzers took 4.751356ms with top 10 stages: buildir: 4.426485ms, U1000: 324.871µs"
12:59:58 level=warning msg="[runner] Can't run linter unused: buildir: failed to load package net: could not load export data: no export data for \"net\""
12:59:58 level=info msg="[runner] processing took 3.333µs with stages: max_same_issues: 636ns, nolint: 420ns, skip_dirs: 402ns, cgo: 283ns, skip_files: 218ns, max_from_linter: 214ns, autogenerated_exclude: 178ns, filename_unadjuster: 177ns, identifier_marker: 169ns, path_prettifier: 129ns, diff: 121ns, uniq_by_line: 111ns, max_per_file_from_linter: 63ns, exclude-rules: 60ns, path_shortener: 53ns, exclude: 51ns, source_code: 48ns"
12:59:58 level=info msg="[runner] linters took 4.532323396s with stages: goanalysis_metalinter: 4.080827626s, unused: 451.456917ms"
12:59:58 level=error msg="Running error: buildir: failed to load package net: could not load export data: no export data for \"net\""
12:59:58 level=info msg="Memory: 48 samples, avg is 439.6MB, max is 605.8MB"
12:59:58 level=info msg="Execution took 4.659162568s"
@CSRaghunandan CSRaghunandan added the bug Something isn't working label Jul 8, 2020
@boring-cyborg
Copy link

boring-cyborg bot commented Jul 8, 2020

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

@SVilgelm
Copy link
Member

SVilgelm commented Jul 9, 2020

How do you run the linter? And what is a structure of your project?
The logs has this error:

Can't run linter unused: buildir: failed to load package net: could not load export data: no export data for "net"

Probably something wrong with you net package

@CSRaghunandan
Copy link
Author

How do you run the linter? And what is a structure of your project?
The logs has this error:

Can't run linter unused: buildir: failed to load package net: could not load export data: no export data for "net"

Probably something wrong with you net package

Hello, I'm running golangci-lint run on the parent directory of the projects src directory.

The same commands works on my linux system with the same version of golang and golangci-lint. I am unable to debug why its failing to run on jenkins. I'm also using go mod for package management with the go.mod file inside the src directory.

Also, I dont think anything is wrong with net package, as I am able to build the project perfectly fine in jenkins

@KenjiTakahashi
Copy link

KenjiTakahashi commented Jul 10, 2020

I was seeing the same problem with Go installed from official binaries (i.e. https://golang.org/doc/install). It turned out that net imports cgo_linux, which in turn is including netdb.h.
Bottom line: needed to install gcc and libc-dev packages.
Guess that (some) linters are not differentiating between pure-Go/CGo based implementations, like the compiler itself does?

EDIT: Actually, explicitly setting CGO_ENABLED=0 seems to work, too.

@CSRaghunandan
Copy link
Author

I was seeing the same problem with Go installed from official binaries (i.e. https://golang.org/doc/install). It turned out that net imports cgo_linux, which in turn is including netdb.h.
Bottom line: needed to install gcc and libc-dev packages.
Guess that (some) linters are not differentiating between pure-Go/CGo based implementations, like the compiler itself does?

EDIT: Actually, explicitly setting CGO_ENABLED=0 seems to work, too.

Thank you @KenjiTakahashi

I was finally able to get it working. I will close the issue as the problem is solved.

andrejtokarcik added a commit to andrejtokarcik/jobworker that referenced this issue Oct 27, 2020
To prevent 'failed to load package net' golangci-lint errors,
cf. golangci/golangci-lint#1219
gabriel-vasile added a commit to gabriel-vasile/mimetype that referenced this issue Apr 17, 2022
Trying to fix a linter problem in codeQL action workflow.
golangci/golangci-lint#1219 (comment)
gabriel-vasile added a commit to gabriel-vasile/mimetype that referenced this issue Apr 17, 2022
* Disable CGO in codeql action

Trying to fix a linter problem in codeQL action workflow.
golangci/golangci-lint#1219 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants