Skip to content

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

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

Closed
rafaelvanoni opened this issue Nov 27, 2019 · 6 comments
Labels
bug Something isn't working

Comments

@rafaelvanoni
Copy link

rafaelvanoni commented Nov 27, 2019

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"

@xulongfei
Copy link

please check the user’s /tmp/golangci-lint.lock access permission

@tpounds tpounds added the bug Something isn't working label Dec 30, 2019
@KevinJoiner
Copy link

KevinJoiner commented Jan 28, 2020

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.

@ernado ernado closed this as completed in bec0985 Feb 4, 2020
@tschaub
Copy link

tschaub commented Feb 27, 2020

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

@tschaub
Copy link

tschaub commented Feb 27, 2020

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

korjavin pushed a commit to korjavin/golangci-lint-1 that referenced this issue Mar 10, 2020
* tag 'v1.23.7': (140 commits)
  dev: prepare v1.23.7
  autogenerated_exclude: increase scanner max buffer size
  dev: use go1.14
  change increase to increasing in timeout error
  dev: release v1.23.6
  tools: update goreleaser
  dev: release v1.23.5
  Support Go 1.14rc1.
  Simplify alpine Dockerfile
  add missing mips option
  Update to latest x/tools (golangci#930)
  fix golangci#869 by removing lock file after unlocking (golangci#947)
  dev: release v1.23.3
  autogenerated_exclude: increase scanner buffer (golangci#955)
  gocritic: update disabled check warning message
  Add MIPS arch support
  dev: release v1.23.2
  Fix misspelled words. (golangci#952)
  Add Intuit to README.md (golangci#936)
  fix golangci.yml reference
  ...
@gbgrout
Copy link

gbgrout commented Aug 13, 2020

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

fburgue pushed a commit to fburgue/terraform-vcloud-linuxvm that referenced this issue Sep 17, 2021
golangci-lint create a lock file in /tmp which prevents multiple invocation
of golanci-lint. Our jenkins build can fail if golangci-lint is already
running on the same slave.

Add arg to prevent creation of that lock file.

refs golangci/golangci-lint#869
@melkus
Copy link

melkus commented Apr 7, 2023

property moved to configuration file
run:
allow-parallel-runners: true

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

7 participants