-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
depguard is enabled and fails on v1.53.0 #3862
depguard is enabled and fails on v1.53.0 #3862
Comments
It's happening with latest version released |
There's an open issue to track it but the maintainer hasn't replied yet OpenPeeDeeP/depguard#46 |
Does the upgrade to v2 need to be reverted? #3795 |
The configuration has changed and it's expected. We will not revert the upgrade. |
It bumped from note: I have no depguard enabled on my side. |
We follow semver but we cannot follow the major version of each linter, then changes inside linter configuration are not considered as breaking. |
I will try to reproduce the problem locally and find a fix. |
Can you provide the output of |
It fails something as simple as a https://github.com/teaxyz/pantry/actions/runs/5148610773/jobs/9271272674 |
I don't have depguard enabled either. |
I need a reproducible context, then I need information. $ golangci-lint version
$ go env
$ cat .golangci.yml
And a public repo. |
|
I need a reproducible context, then I need information. $ golangci-lint version
$ go env
$ cat .golangci.yml
And a public repo. |
$ mkdir foo
$ cd foo
$ golangci-lint version
ERRO [linter] depguard: create analyzer: couldn't expand $gostd: could not read GOROOT directory: open src: no such file or directory
must have an Allow and/or Deny package list
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/jacob/Library/Caches/go-build"
GOENV="/Users/jacob/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/jacob/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/jacob/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/jacob/.tea/go.dev/v1.20.4"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/jacob/.tea/go.dev/v1.20.4/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.4"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/t5/180fzzln0k7_0cgpzmkx2_w80000gn/T/go-build2213119517=/tmp/go-build -gno-record-gcc-switches -fno-common"
$ cat .golangci.yml
cat: .golangci.yml: No such file or directory edited to add: even just $ tea +golangci-lint.run=1.52.2 golangci-lint version
installed: ~/.tea/golangci-lint.run/v1.52.2
golangci-lint has version 1.52.2 built with go1.20.2 from da04413a on 2023-03-25T18:11:28Z
$ tea +golangci-lint.run=1.53.0 golangci-lint version
ERRO [linter] depguard: create analyzer: couldn't expand $gostd: could not read GOROOT directory: open src: no such file or directory
must have an Allow and/or Deny package list |
I think I know the root of the problem: https://github.com/OpenPeeDeeP/depguard/blob/84475ef6d579f85ae86343f549bd9c267d3b7993/internal/utils/variables.go#L48 The use of |
I'm working on a fix, give me some time. |
Thank you @ldez if you need an example on a public repo - I've got it failing here https://github.com/go-co-op/gocron/actions/runs/5149340859/jobs/9272212188 |
I have a public repo which has the failure as well moov-io/infra#271 |
I am still not able to reproduce it locally. I created a simple app just to display package main
import (
"fmt"
"go/build"
)
func main() {
fmt.Println(build.Default.GOROOT)
} $ ./sandbox
/usr/lib/go $ ./sandbox
/home/ldez/.gvm/gos/go1.20.4 $ GOROOT=fofo ./sandbox
fofo
2023/06/02 00:01:38 open fofo: no such file or directory |
What I'm sure about:
the message This directory ( And 2 users have the same error message with this directory ( Based on jobs/9271272674 it fails on all OS. jobs/9272212188 and jobs/9271486191 failed on liunx amd64. |
I'm on macOS right now and Go is installed via homebrew.
|
$ golangci-lint version
golangci-lint has version 1.53.0 built with go1.20.4 from 9f2528a3 on 2023-06-01T19:43:45Z $ git clone [email protected]:moov-io/infra.git
Cloning into 'infra'...
remote: Enumerating objects: 9277, done.
remote: Counting objects: 100% (96/96), done.
remote: Compressing objects: 100% (60/60), done.
remote: Total 9277 (delta 42), reused 86 (delta 36), pack-reused 9181
Receiving objects: 100% (9277/9277), 3.93 MiB | 1.45 MiB/s, done.
Resolving deltas: 100% (5751/5751), done.
$ cd infra
$ golangci-lint run
$ $ git clone [email protected]:go-co-op/gocron.git
Cloning into 'gocron'...
remote: Enumerating objects: 1746, done.
remote: Counting objects: 100% (314/314), done.
remote: Compressing objects: 100% (161/161), done.
remote: Total 1746 (delta 218), reused 234 (delta 149), pack-reused 1432
Receiving objects: 100% (1746/1746), 592.91 KiB | 1.54 MiB/s, done.
Resolving deltas: 100% (1158/1158), done.
$ cd gocron
$ golangci-lint run
scheduler.go:1178:11: superfluous-else: if block ends with a break statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
} else {
repeatMap[dayOfMonth]++
}
scheduler_test.go:26:24: unused-parameter: parameter 'i' seems to be unused, consider removing or renaming it as _ (revive)
func (f fakeTime) Unix(i int64, i2 int64) time.Time {
^
scheduler_test.go:2356:54: unused-parameter: parameter 't' seems to be unused, consider removing or renaming it as _ (revive)
func TestScheduler_CheckSetBehaviourBeforeJobCreated(t *testing.T) {
^
$ I'm on Linux amd64. |
can someone try this command: GOROOT=<YOUR REAL GOROOT> golangci-lint version |
I can reproduce this with the following Dockerfile.
Building that fails with the following.
Edit: If I setup a new GOROOT which matches the v1.53.0 builder release path the issue goes away, so it does appear to be a mismatch of the build's GOROOT and the runtime GOROOT. Add the following steps to the Dockerfile allows
Jumping into the completed Docker image shows a working GOROOT.
|
Thank you, I can reproduce it now. $ docker run --rm -it golang:1.20-alpine sh
/go # wget https://github.com/golangci/golangci-lint/releases/download/v1.53.0/golangci-lint-1.53.0-linux-amd64.tar.gz
Connecting to github.com (140.82.121.4:443)
Connecting to objects.githubusercontent.com (185.199.109.133:443)
saving to 'golangci-lint-1.53.0-linux-amd64.tar.gz'
golangci-lint-1.53.0 100% |********************************************************************************************************************************************************************************************| 9760k 0:00:00 ETA
'golangci-lint-1.53.0-linux-amd64.tar.gz' saved
/go # tar xf golangci-lint-1.53.0-linux-amd64.tar.gz
/go # go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/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.20.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3482902365=/tmp/go-build -gno-record-gcc-switches"
/go # /go/golangci-lint-1.53.0-linux-amd64/golangci-lint version
ERRO [linter] depguard: create analyzer: must have an Allow and/or Deny package list
/go # GOROOT=$(go env GOROOT) /go/golangci-lint-1.53.0-linux-amd64/golangci-lint version
golangci-lint has version 1.53.0 built with go1.20.4 from 9f2528a3 on 2023-06-01T19:43:45Z
If I set the |
More information: the problem appears even if you don't use Another example of why I hate global variables 😢 |
See golangci/golangci-lint#3862 Signed-off-by: Marc 'risson' Schmitt <[email protected]>
See golangci/golangci-lint#3862 Signed-off-by: Marc 'risson' Schmitt <[email protected]>
See golangci/golangci-lint#3862 Signed-off-by: Marc 'risson' Schmitt <[email protected]>
Thanks for the quick resolution folks! 👏 |
See golangci/golangci-lint#3862 Signed-off-by: Marc 'risson' Schmitt <[email protected]>
I know this is a year old, but picking it up now. If I understand correctly, after this fix, if you do not have depguard enabled, everything should work. And, indeed, running If you use |
We don't use a fork now and you don't need to disable it. You should update your configuration: https://golangci-lint.run/usage/linters/#depguard |
Thanks @ldez . |
Welcome
Description of the problem
Running v1.53.0 of golangci-lint seems to enable
depguard
and fails due to a config error.Version of golangci-lint
Configuration file
Go environment
Verbose output of running
Code example or link to a public repository
Updating golangci-lint to v1.53.0 in https://github.com/moov-io/infra/blob/master/go/lint-project.sh
CI run: https://github.com/moov-io/infra/actions/runs/5149020788/jobs/9271486191
The text was updated successfully, but these errors were encountered: