-
-
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
When GOPATH is unset, context loading failed: no go files to analyze #3828
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
Hello, In the "Go environment" section of your issue:
Can you provide the |
Hello! Thanks for taking a look at this. The For completeness, here's the output of both When the problem occurs: $ env
HOSTNAME=4dfda16b9aa5
container=oci
PWD=/usr/local/src/ocm-operator
HOME=/root
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/go/bin
_=/usr/bin/env
$ 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="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/root/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/root/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/usr/local/src/ocm-operator/go.mod"
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-build4048270693=/tmp/go-build -gno-record-gcc-switches" When the problem does not occur: $ env
HOSTNAME=56d1dd94a9f4
container=oci
GOPATH=/root/go
PWD=/usr/local/src/ocm-operator
HOME=/root
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/go/bin
_=/usr/bin/env
$ 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="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/root/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/root/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/usr/local/src/ocm-operator/go.mod"
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-build3248282909=/tmp/go-build -gno-record-gcc-switches" |
I believe I just experienced this as well. It seems to be related to the fact that go wants to use the user's |
Welcome
Description of the problem
Hello! I've encountered a situation where golanglint-ci runs correctly when the
GOPATH
environment variable is set to its default value (GOPATH=$HOME/go
or evenGOPATH=$(go env GOPATH)
, but whenGOPATH
is unset, golanglint-ci fails withRunning error: context loading failed: no go files to analyze
. I believe this is a different root cause than #825 because the code builds and tests successfully, but I'm happy to move this into #825 if you believe it should be there instead.I saw this behavior on RHEL 8.7. I've included a Dockerfile reproducer, although I haven't yet attempted to narrow down the linter set or source file set that cause this behavior yet.
Building this Dockerfile with
docker build .
orpodman build .
results in the "Verbose output of running" section below.However, if the last line of the Dockerfile is changed to
RUN GOPATH=$HOME/go golangci-lint run --verbose
the output changes to
I have confirmed that when I introduce lint errors into the source code, they are correctly identified once GOPATH is set.
(The warning from gomoddirectives can be ignored, this appears to be a separate bug where gomoddirectives is attempting to parse output from
go list -m -json
but choking on a warning being output).Please let me know if there's any additional information I can provide, or if you'd like me to try to narrow anything down further.
Thank you for all your work on golangci-lint!
Version of golangci-lint
Configuration file
Go environment
Verbose output of running
Code example or link to a public repository
https://github.com/rh-mobb/ocm-operator/tree/e26aad059f3772f608a9388522efdf314c5fd461
The text was updated successfully, but these errors were encountered: