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

Can't run linter goanalysis_metalinter: failed prerequisites #827

Closed
3 tasks done
nono opened this issue Oct 18, 2019 · 86 comments
Closed
3 tasks done

Can't run linter goanalysis_metalinter: failed prerequisites #827

nono opened this issue Oct 18, 2019 · 86 comments
Labels
bug Something isn't working

Comments

@nono
Copy link

nono commented Oct 18, 2019

Sometimes, when running golangci-lint on https://github.com/cozy/cozy-stack, I have a warning about failed_prerequisites:

WARN [runner] Can't run linter goanalysis_metalinter: fact_purity: failed prerequisites: [email protected]/cozy/cozy-stack/model/instance/lifecycle [github.com/cozy/cozy-stack/model/app.test]
  • 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
$ golangci-lint --version
golangci-lint has version 1.21.0 built from 645e794 on 2019-10-15T18:16:56Z
Config file
$ cat .golangci.yml
cat: .golangci.yml: No such file or directory
Go environment
$ go version && go env
go version go1.13.1 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/nono/.cache/go-build"
GOENV="/home/nono/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/nono/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/nix/store/2kzdq7gyxz9jqfqcrp97z2y03vbw4glc-go-1.13.1/share/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/nix/store/2kzdq7gyxz9jqfqcrp97z2y03vbw4glc-go-1.13.1/share/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="/nix/store/7hzmz83nv8khpwsk858yaac7y3idh0a7-gcc-wrapper-8.3.0/bin/cc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/nono/cc/stack/go.mod"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build302705204=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /home/nono/cc/stack /home/nono/cc /home/nono /home /] 
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck] 
INFO [loader] Go packages loading at mode 575 (exports_file|types_sizes|compiled_files|deps|files|imports|name) took 2.691690133s 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 70.353413ms 
INFO [runner/unused/goanalysis] analyzers took 5.857582585s with top 10 stages: buildssa: 4.867487779s, U1000: 990.094806ms 
INFO [runner/goanalysis_metalinter/goanalysis] analyzers took 9.763996494s with top 10 stages: buildssa: 4.693446351s, ineffassign: 503.987592ms, vrp: 405.948511ms, inspect: 367.360506ms, varcheck: 167.809469ms, SA4018: 166.777714ms, isgenerated: 163.478578ms, deadcode: 160.6481ms, errcheck: 147.053834ms, structcheck: 142.659624ms 
WARN [runner] Can't run linter goanalysis_metalinter: ctrlflow: failed prerequisites: [email protected]/cozy/cozy-stack/web/accounts [github.com/cozy/cozy-stack/web/middlewares.test] 
INFO [runner] processing took 4.732µs with stages: max_same_issues: 1.074µs, skip_dirs: 500ns, cgo: 493ns, nolint: 373ns, filename_unadjuster: 361ns, max_from_linter: 303ns, exclude: 226ns, skip_files: 201ns, path_prettifier: 200ns, uniq_by_line: 170ns, identifier_marker: 154ns, max_per_file_from_linter: 140ns, diff: 138ns, path_shortener: 134ns, autogenerated_exclude: 89ns, source_code: 89ns, exclude-rules: 87ns 
INFO [runner] linters took 3.157498783s with stages: unused: 1.664301241s, goanalysis_metalinter: 1.493144531s 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 60 samples, avg is 407.5MB, max is 1076.4MB 
INFO Execution took 5.924849209s
@jirfag jirfag added the bug Something isn't working label Oct 18, 2019
@dixonwille
Copy link

I feel like this is related #824

@amber-zhang
Copy link

amber-zhang commented Nov 7, 2019

Hi I met same problem.

$ golangci-lint run -v main.go
INFO [config_reader] Config search paths: [./ /home/ibmadmin/github.ibm.com/spectrum-virtualize-exporter /home/ibmadmin/github.ibm.com /home/ibmadmin /home /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 30 linters: [deadcode depguard dogsled dupl errcheck funlen gochecknoinits goconst gocritic gocyclo gofmt goimports golint gosec gosimple govet ineffassign interfacer lll misspell nakedret scopelint staticcheck structcheck stylecheck typecheck unconvert unparam varcheck whitespace] 
INFO [loader] Go packages loading at mode 575 (name|types_sizes|deps|exports_file|files|imports|compiled_files) took 322.014245ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 671.191µs 
INFO [runner/goanalysis_metalinter/goanalysis] analyzers took 2.392766ms with top 10 stages: fact_deprecated: 458.401µs, buildssa: 114.037µs, inspect: 112.347µs, printf: 54.367µs, ctrlflow: 49.075µs, fact_purity: 43.913µs, depguard: 25.28µs, unparam: 23.584µs, S1034: 22.43µs, SA1001: 20.957µs 
WARN [runner] Can't run linter goanalysis_metalinter: S1008: failed prerequisites: inspect@command-line-arguments, isgenerated@command-line-arguments 
INFO [runner] processing took 6.1µs with stages: max_same_issues: 1.653µs, skip_dirs: 680ns, cgo: 596ns, nolint: 586ns, skip_files: 320ns, max_from_linter: 304ns, exclude: 278ns, filename_unadjuster: 265ns, identifier_marker: 248ns, path_prettifier: 179ns, path_shortener: 172ns, diff: 167ns, uniq_by_line: 165ns, source_code: 163ns, max_per_file_from_linter: 159ns, autogenerated_exclude: 93ns, exclude-rules: 72ns 
INFO [runner] linters took 521.726734ms with stages: goanalysis_metalinter: 521.624518ms 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 10 samples, avg is 88.4MB, max is 134.8MB 
INFO Execution took 880.10069ms                   
$ go version
go version go1.12.9 linux/amd64
$ golangci-lint version
golangci-lint has version 1.21.0 built from 645e794 on 2019-10-15T18:16:56Z

@avnindersingh
Copy link

avnindersingh commented Nov 8, 2019

i am also seeing the same issue ... any workaround will be helpful...

@opskumu
Copy link

opskumu commented Nov 12, 2019

+1 same problem

WARN [runner] Can't run linter goanalysis_metalinter: SA2003: failed prerequisites: buildssa@command-line-arguments
➜  ~ golangci-lint version
golangci-lint has version v1.21.1-0.20191111000716-14ebae29060f built from (unknown, mod sum: "h1:J9Xwp1uY0EooAwj8OONV3bbgfAChsFdOMfFzH5eWcnQ=") on (unknown)
➜  ~ go version
go version go1.13.4 darwin/amd64
➜  ~

@t57root
Copy link

t57root commented Nov 17, 2019

same error. Rerun the command then the problem go away.

@Am6er
Copy link

Am6er commented Nov 19, 2019

confirm

amber@AmberMac Test % cat test.go              
package main

func main() {
amber@AmberMac Test % golangci-lint run test.go
WARN [runner] Can't run linter goanalysis_metalinter: vrp: failed prerequisites: buildssa@command-line-arguments 
WARN [runner] Can't run linter unused: buildssa: analysis skipped: errors in package: [/Users/amber/Test/test.go:4:2: expected '}', found 'EOF' /Users/amber/Test/test.go:4:2: expected '}', found 'EOF'] 
amber@AmberMac Test % golangci-lint version
golangci-lint has version 1.21.0 built from 645e794 on 2019-10-15T18:15:04Z

@durban89
Copy link

durban89 commented Nov 20, 2019

+1 same error

$ golangci-lint run --fast --out-format tab main.go
WARN [runner] Can't run linter goanalysis_metalinter: S1011: failed prerequisites: inspect@command-line-arguments, isgenerated@command-line-arguments
$ golangci-lint --version
golangci-lint has version 1.21.0 built from 645e794 on 2019-10-15T18:15:04Z
$ go version
go version go1.13.1 darwin/amd64

@alvarolm
Copy link

alvarolm commented Nov 20, 2019

same here:

golangci-lint has version 1.21.0 built from 645e794 on 2019-10-15T18:16:56
go version go1.13.4 linux/amd64
$ golangci-lint run .                                                                                                                                                                                   
WARN [runner] Can't run linter goanalysis_metalinter: assign: failed prerequisites: inspect@pactado/securer 
WARN [runner] Can't run linter unused: buildssa: analysis skipped: errors in package: [/home/alvarolm/dev/assets/go/src/pr/main.go:39:25: ReadFile not declared by package ioutil] 
$ golangci-lint run .
WARN [runner] Can't run linter goanalysis_metalinter: SA4001: failed prerequisites: inspect@pactado/securer 
WARN [runner] Can't run linter unused: buildssa: analysis skipped: errors in package: [/home/alvarolm/dev/assets/go/src/pr/main.go:39:25: ReadFile not declared by package ioutil] 

@yangwenmai
Copy link

+1 same problem

[WARN] golangci-lint ctrlflow: failed prerequisites

➜  ~ golangci-lint version
golangci-lint has version 1.21.0 built from 645e794 on 2019-10-15T18:15:04Z
➜  ~ go version
go version go1.13.5 darwin/amd64

@awoodbeck
Copy link

This issue appears to be introduce with commit 95ec0cf.

@hiromaily

This comment has been minimized.

rhcarvalho added a commit to rhcarvalho/sentry-go that referenced this issue Dec 13, 2019
The current recommended installation steps use githubusercontent.com
instead of goreleaser.com. There has been a reported issue in which the
installer code differed between the two sites.
golangci/golangci-lint#575

Additionally, pin to a specific tagged version of the install script to
ensure reproducible installations of the tool.

Use version 1.19.1.

The latest two releases (1.21.0, 1.20.0) have a flaky bug (at least on
macOS) that prevents the linter to run while still exiting with code 0
(success).

```
~/s/sentry-go ❯❯❯ golangci-lint run
WARN [runner] Can't run linter goanalysis_metalinter: assign: failed
prerequisites: [email protected]/getsentry/sentry-go/echo
~/s/sentry-go ❯❯❯ golangci-lint run
WARN [runner] Can't run linter goanalysis_metalinter: interfacer: failed
prerequisites: [email protected]/getsentry/sentry-go/echo
```

See
- golangci/golangci-lint#866
- golangci/golangci-lint#827
rhcarvalho added a commit to rhcarvalho/sentry-go that referenced this issue Dec 13, 2019
The current recommended installation steps use githubusercontent.com
instead of goreleaser.com. There has been a reported issue in which the
installer code differed between the two sites.
golangci/golangci-lint#575

Additionally, pin to a specific tagged version of the install script to
ensure reproducible installations of the tool.

Use version 1.19.1.

The latest two releases (1.21.0, 1.20.0) have a flaky bug (at least on
macOS) that prevents the linter to run while still exiting with code 0
(success).

```
~/s/sentry-go ❯❯❯ golangci-lint run
WARN [runner] Can't run linter goanalysis_metalinter: assign: failed
prerequisites: [email protected]/getsentry/sentry-go/echo
~/s/sentry-go ❯❯❯ golangci-lint run
WARN [runner] Can't run linter goanalysis_metalinter: interfacer: failed
prerequisites: [email protected]/getsentry/sentry-go/echo
```

See
- golangci/golangci-lint#866
- golangci/golangci-lint#827
rhcarvalho added a commit to getsentry/sentry-go that referenced this issue Dec 13, 2019
The current recommended installation steps use githubusercontent.com
instead of goreleaser.com. There has been a reported issue in which the
installer code differed between the two sites.
golangci/golangci-lint#575

Additionally, pin to a specific tagged version of the install script to
ensure reproducible installations of the tool.

Use version 1.19.1.

The latest two releases (1.21.0, 1.20.0) have a flaky bug (at least on
macOS) that prevents the linter to run while still exiting with code 0
(success).

```
~/s/sentry-go ❯❯❯ golangci-lint run
WARN [runner] Can't run linter goanalysis_metalinter: assign: failed
prerequisites: [email protected]/getsentry/sentry-go/echo
~/s/sentry-go ❯❯❯ golangci-lint run
WARN [runner] Can't run linter goanalysis_metalinter: interfacer: failed
prerequisites: [email protected]/getsentry/sentry-go/echo
```

See
- golangci/golangci-lint#866
- golangci/golangci-lint#827
@nakabonne

This comment has been minimized.

@lhopki01

This comment has been minimized.

@zhqqqy
Copy link

zhqqqy commented Dec 20, 2019

v1.19.1 is ok for me

@aimpsmile

This comment has been minimized.

@dvaldivia
Copy link

dvaldivia commented Dec 31, 2019

also happens on v1.22.2

✗ golangci-lint version
golangci-lint has version 1.22.2 built from cb2f8ba on 2019-12-30T19:26:28Z

@sgunwar
Copy link

sgunwar commented Jan 2, 2020

Any solution to this issue. It still keeps failing on using v1.22.2 for gitlab CI/CD.

@barendlinders

This comment has been minimized.

@tpounds
Copy link
Contributor

tpounds commented Jan 4, 2020

This definitely seems like a widespread issue. Can some of you seeing the problem provide links to public repositories that can reliably reproduce the issue? Also, any links to public CI failures would be helpful as well. Having a way to reproduce the problem should make it easier to diagnose the root cause.

@guesslin
Copy link

guesslin commented Jan 6, 2020

Update

I'm trying to build the code first and found the code is not compilable. After fixing those uncompilable part, I don't see this problem happen again, and can report the linter messages.

# golangci-lint run
WARN [runner] Can't run linter goanalysis_metalinter: ST1016: failed prerequisites: buildssa@<package path>
# golangci-lint version
golangci-lint has version 1.21.0 built from 645e794 on 2019-10-15T18:16:56Z
# go version
go version go1.13.5 linux/amd64

@coderanger
Copy link

We have also been seeing this intermittently. It will fail at random and the succeed on the same commit once re-run.

@duduwe
Copy link

duduwe commented Apr 20, 2020

Sharing how I resolved mine. Aside from there is something that I had to fix in my project folder, it also has something to do with golangci-lint behaviour. It wasn't consistent with its error. I am using golangci-lint v1.22.2. Here are the steps I performed:

  • Replaced installation from v1.22.2 to v1.23.8. I think it doesn't matter what version. The first time I encountered this issue, I used v1.24.0. Reinstalling seems to refresh the environment. I really don't know. curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.8
  • Execute golangci-lint cache clean, just an additional step to clear the environment. Again, I really don't know why.
  • Execute golangci-lint run. At this point, I inspected the 1st and 2nd WARNING lines and they gave me a hint. I had testFile.go of package main. There was a redeclaration of main. I did not encounter this issue in the 1st version which it should had printed as one of the WARNING/ERRORS. By the way, compilation and building via vscode worked just fine.
  • I removed the test files. They were in the same folder as the legit main.go. golangci-lint run already worked after that -- already getting lint recommendations.
  • Reverted back to v1.22.2

It was a weird and painful ordeal. Anyone have an idea what's going on?
Anyhow, hope these steps would help resolve your issue.

@sbinet
Copy link

sbinet commented Jun 19, 2020

we are also seeing this issue -via golangci-lint-actions- when updating gonum/plot to use Gioui (that uses cgo under the hood to interact with the graphics layer of the OS)

gonum/plot#628

anything we could do on our end?

@sbinet
Copy link

sbinet commented Jun 19, 2020

FYI, golangci-lint-actions was failing to analyze the CGo dependencies b/c while the build GitHub Action did have all the required C/C++ packages installed, the golangci-lint GitHub Action didn't (they are executed in distinct environments/containers).

adding a run-step with the appropriate apt install xxx command fixed it.

@andig
Copy link

andig commented Jul 6, 2020

This is still happening with 1.28, both locally and on CI:

local:

golangci-lint run
WARN [runner/goanalysis_metalinter/goanalysis] Failed to get persisted facts: failed to get data from low-level cache by key buildir/facts for package utf8: failed to stat file /Users/andig/Library/Caches/golangci-lint/e2/e24a307ec1d4f19e6023639f91a2b1e33a9a2bbadcba08e4b8a7765245b19de7-d: stat /Users/andig/Library/Caches/golangci-lint/e2/e24a307ec1d4f19e6023639f91a2b1e33a9a2bbadcba08e4b8a7765245b19de7-d: no such file or directory 
WARN [runner/goanalysis_metalinter/goanalysis] Failed to get persisted facts: failed to get data from low-level cache by key buildir/facts for package sys: failed to stat file /Users/andig/Library/Caches/golangci-lint/e2/e24a307ec1d4f19e6023639f91a2b1e33a9a2bbadcba08e4b8a7765245b19de7-d: stat /Users/andig/Library/Caches/golangci-lint/e2/e24a307ec1d4f19e6023639f91a2b1e33a9a2bbadcba08e4b8a7765245b19de7-d: no such file or directory 
WARN [runner/goanalysis_metalinter/goanalysis] Failed to get persisted facts: failed to get data from low-level cache by key buildir/facts for package runtime: failed to stat file /Users/andig/Library/Caches/golangci-lint/7c/7ce4893d66ce16c2624776544473b68fafe330e74224c8522588ecee92ee9e7c-d: stat /Users/andig/Library/Caches/golangci-lint/7c/7ce4893d66ce16c2624776544473b68fafe330e74224c8522588ecee92ee9e7c-d: no such file or directory 
WARN [runner/goanalysis_metalinter/goanalysis] Failed to get persisted facts: failed to get data from low-level cache by key buildir/facts for package syscall: failed to stat file /Users/andig/Library/Caches/golangci-lint/26/2679eabe877eea105e62e7316dad9a6c482eeb95f9bbe09a4ccfd32d0c790e86-d: stat /Users/andig/Library/Caches/golangci-lint/26/2679eabe877eea105e62e7316dad9a6c482eeb95f9bbe09a4ccfd32d0c790e86-d: no such file or directory 
WARN [runner/goanalysis_metalinter/goanalysis] Failed to get persisted facts: failed to get data from low-level cache by key buildir/facts for package fmt: failed to stat file /Users/andig/Library/Caches/golangci-lint/10/10a1358a7c3f0744ce77b1a8380e4bd9af94c864b08e9d452bde8c6fce741d2e-d: stat /Users/andig/Library/Caches/golangci-lint/10/10a1358a7c3f0744ce77b1a8380e4bd9af94c864b08e9d452bde8c6fce741d2e-d: no such file or directory 
WARN [runner/goanalysis_metalinter/goanalysis] Failed to get persisted facts: failed to get data from low-level cache by key buildir/facts for package json: failed to stat file /Users/andig/Library/Caches/golangci-lint/01/01804f1ca8b01ff89900506df197abf4a10b565f6d7eee270f80bca0eff0e3d5-d: stat /Users/andig/Library/Caches/golangci-lint/01/01804f1ca8b01ff89900506df197abf4a10b565f6d7eee270f80bca0eff0e3d5-d: no such file or directory 
WARN [runner/goanalysis_metalinter/goanalysis] Failed to get persisted facts: failed to get data from low-level cache by key buildir/facts for package yaml: failed to stat file /Users/andig/Library/Caches/golangci-lint/00/00101f8ad23a6f0b4f857af8ded9d7a43569006ae03c3d4bf6f793cfe8dd8a8f-d: stat /Users/andig/Library/Caches/golangci-lint/00/00101f8ad23a6f0b4f857af8ded9d7a43569006ae03c3d4bf6f793cfe8dd8a8f-d: no such file or directory 
WARN [runner/goanalysis_metalinter/goanalysis] Failed to get persisted facts: failed to get data from low-level cache by key buildir/facts for package toml: failed to stat file /Users/andig/Library/Caches/golangci-lint/28/28804e8e8ea9079276a8b08534a16a3a794e23123f14f810392b4887d50ed653-d: stat /Users/andig/Library/Caches/golangci-lint/28/28804e8e8ea9079276a8b08534a16a3a794e23123f14f810392b4887d50ed653-d: no such file or directory 

It is an intermittent issue, rerunning always solves this type of problem.

Could we please reopen this issue?

@iwankgb iwankgb reopened this Jul 12, 2020
@iwankgb
Copy link
Contributor

iwankgb commented Jul 12, 2020

According to comment above it is still an issue.

@TheHackerDev
Copy link

Below is what finally fixed the issue for me.

I found that my IDE (IntelliJ IDEA) was actually putting in a GOROOT and GOPATH environment variable when running golangci-lint as a file watcher (automatically run whenever a file change and save occurs). When I removed these environment variables and allowed it to use my system environment variables, I no longer got the error message of Can't run linter goanalysis_metalinter: S1006: failed prerequisites.

Basically, my IDE was messing with my GOROOT and GOPATH environment variables, and that's why I was getting a bunch of errors about not being able to import any packages (even from the standard library). This may not work for you, but it's worth checking out what's going on with these environment variables when you run golangci-lint.

wadells added a commit to wadells/robotest that referenced this issue Aug 24, 2020
Bumping go required bumping golangci-lint due to the following error:

  level=warning msg="[runner] Can't run linter goanalysis_metalinter: SA1023: failed prerequisites: [email protected]/gravitational/robotest/lib/loc"

Which is discussed here:

  golangci/golangci-lint#827

Bumping golangci-lint in turn required tweaking (or removing) a test
that would never run:

  lib/ssh/ssh_test.go:86:6: func `testEnv` is unused (unused)

I chose to enable the test, as ssh_test.go is not run regularly, and
I don't fully understand the impact of removing the env parameter from
RunAndParse. Better to let someone sort it out when they try to execute
ssh_test.go and have more context available.
wadells added a commit to gravitational/robotest that referenced this issue Aug 24, 2020
Bumping go required bumping golangci-lint due to the following error:

  level=warning msg="[runner] Can't run linter goanalysis_metalinter: SA1023: failed prerequisites: [email protected]/gravitational/robotest/lib/loc"

Which is discussed here:

  golangci/golangci-lint#827

Bumping golangci-lint in turn required tweaking (or removing) a test
that would never run:

  lib/ssh/ssh_test.go:86:6: func `testEnv` is unused (unused)

I chose to enable the test, as ssh_test.go is not run regularly, and
I don't fully understand the impact of removing the env parameter from
RunAndParse. Better to let someone sort it out when they try to execute
ssh_test.go and have more context available.
@wwolfe
Copy link

wwolfe commented Jan 14, 2021

docker run --rm -v /appdir:/app -w /app golangci/golangci-lint:v1.22.2 golangci-lint run -v
it fails locally but if I run in this container it works fine, work around for now?

@ldez
Copy link
Member

ldez commented Jan 14, 2021

you have to use a more recent version: v1.35.2

@Harkishen-Singh
Copy link

I am still facing this issue. (version: version 1.35.2 built from 1da5701 on 2021-01-11T02:54:03Z)

logs

WARN [runner] Can't run linter goanalysis_metalinter: S1006: failed prerequisites: [([email protected]/timescale/promscale/pkg/internal/testhelpers [github.com/timescale/promscale/pkg/internal/testhelpers.test], [email protected]/timescale/promscale/pkg/internal/testhelpers [github.com/timescale/promscale/pkg/internal/testhelpers.test]): analysis skipped: errors in package: [/home/hsingh/go/src/github.com/timescale/promscale/pkg/internal/testhelpers/containers.go:23:17: could not import github.com/testcontainers/testcontainers-go (/home/hsingh/go/pkg/mod/github.com/testcontainers/[email protected]/container.go:9:2: could not import github.com/docker/docker/pkg/archive (/home/hsingh/go/pkg/mod/github.com/docker/[email protected]+incompatible/pkg/archive/archive_unix.go:84:9: RunningInUserNS not declared by package sys))]] 
WARN [runner] Can't run linter unused: buildir: failed to load package archive: could not load export data: no export data for "github.com/docker/docker/pkg/archive" 
ERRO Running error: buildir: failed to load package archive: could not load export data: no export data for "github.com/docker/docker/pkg/archive" 

Any work-around for this?

@ldez
Copy link
Member

ldez commented Jan 23, 2021

@Harkishen-Singh how to reproduce your error? Could you provide the source, your configuration, the go version, etc? Thank you

edit: I found your PR timescale/promscale#445

@ldez
Copy link
Member

ldez commented Jan 23, 2021

In fact the error is clear: RunningInUserNS not declared by package sys

analysis skipped: errors in package: [
  /home/hsingh/go/src/github.com/timescale/promscale/pkg/internal/testhelpers/containers.go:23:17: could not import github.com/testcontainers/testcontainers-go
  (/home/hsingh/go/pkg/mod/github.com/testcontainers/[email protected]/container.go:9:2: could not import github.com/docker/docker/pkg/archive
  (/home/hsingh/go/pkg/mod/github.com/docker/[email protected]+incompatible/pkg/archive/archive_unix.go:84:9: RunningInUserNS not declared by package sys))
  ]

the symbol sys.RunningInUserNS is missing because you are using a version of github.com/containerd/containerd/sys that not contains this symbol.

The problem is related to an incompatibility between the version of github.com/docker/docker and the version of github.com/containerd/containerd/sys

$ go mod why github.com/containerd/containerd/sys
# github.com/containerd/containerd/sys
github.com/timescale/promscale/pkg/internal/testhelpers
github.com/testcontainers/testcontainers-go
github.com/docker/docker/pkg/archive
github.com/containerd/containerd/sys

So the problem is not related to golangci-lint.

You can see the problem like that:

$ go test ./pkg/internal/testhelpers/
# github.com/docker/docker/pkg/archive
../../../../pkg/mod/github.com/docker/[email protected]+incompatible/pkg/archive/archive_unix.go:84:5: undefined: "github.com/containerd/containerd/sys".RunningInUserNS
FAIL    github.com/timescale/promscale/pkg/internal/testhelpers [build failed]
FAIL

@ldez
Copy link
Member

ldez commented Jan 23, 2021

For everybody,

The error that begins with Can't run linter goanalysis_metalinter: S1006: failed prerequisites: is in 99% of the cases related to something that doesn't build in your code.

Because golangci-lint requires that your code compile to be analyzed.

I close this issue.

Please report any unexpected errors reported by failed prerequisites as separate issues, thanks!

@ldez ldez closed this as completed Jan 23, 2021
@golangci golangci locked as resolved and limited conversation to collaborators Jan 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests