golangci-lint fails with level=error msg="Parallel golangci-lint is running"

Created on 27 Nov 2019  路  5Comments  路  Source: golangci/golangci-lint

Just downloaded v1.21.0 and started running into this error

Starting with UID : 1003 level=error msg="Parallel golangci-lint is running"

I have no .golangci.yml file and I'm not passing any options to it, just golangci-lint run. It's not even printing a help message if I pass -h to it.

$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/go-cache"
GOENV="/home/user/.config/go/env"
GOEXE=""
GOFLAGS="-mod=vendor"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
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"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/go/src/github.com/projectcalico/libcalico-go/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build253984656=/tmp/go-build -gno-record-gcc-switches"

bug

Most helpful comment

For those seeing this failure with newer versions, just add "--allow-parallel-runners" to your golangci-lint call.

All 5 comments

please check the user鈥檚 /tmp/golangci-lint.lock access permission

I have run into this issue as well.
The problem occurs on systems or servers with multiple users.

func (e *Executor) acquireFileLock() bool {
    lockFile := filepath.Join(os.TempDir(), "golangci-lint.lock")

os.TempDir() is '/tmp' for all users on RedHat 7. Which means the first user to run the golangci-lint will own the file, and no user other than root may lock the file since they do not have proper file permissions.

func (e *Executor) releaseFileLock() {
    if err := e.flock.Unlock(); err != nil {

The above code does unlcock the file, but it does not delete the file which means even after execution other users are still unable to lock said file. See the note below from godoc on flock.Flock Unlock

func (*Flock) Unlock 
func (f *Flock) Unlock() error
Unlock is a function to unlock the file. This file takes a RW-mutex lock, so while it is running the Locked() and RLocked() functions will be blocked. 
This function short-circuits if we are unlocked already. If not, it calls syscall.LOCK_UN on the file and closes the file descriptor. It does not remove the file from disk. It's up to your application to do.  

To fix this I believe the file should be deleted in the release function.
My current fix is changing the file permissions so all users can lock the file.

I've just upgraded to [email protected] (using brew) in hopes of getting around this issue.
Unfortunately:

golangci-lint --help
ERRO Parallel golangci-lint is running

I'm not able to find a golangci-lint.lock to remove...

It turns out there were actually multiple instances of golangci-lint running. They are gone now.

For those seeing this failure with newer versions, just add "--allow-parallel-runners" to your golangci-lint call.

Was this page helpful?
0 / 5 - 0 ratings