xxpxxxxp / intellij-plugin-golangci-lint

GolangCI-Lint integration for IDEA
GNU General Public License v3.0
223 stars 14 forks source link

Error using plugin when modules mode off #123

Closed chrisnappin closed 2 years ago

chrisnappin commented 2 years ago

Hi,

I'm using v1.6.0 of the plugin with GoLand 2022.2.2 (Build #GO-222.3739.57 built on August 16,2022) and we're getting the commonly reporting "Go linter running error Please make sure no syntax or config error, then run 'go mody tidy' to ensure deps ok" error.

Our environment is as follows:

Our project builds and runs within GoLand and at the command line, and golangci-lint happily runs at the command line.

The IDE error log is as follows (some details anonymised):

2022-09-05 12:25:44,805 [1857406]   INFO - #c.i.i.a.RevealFileAction - Exit code 1
2022-09-05 12:25:50,557 [1863158]   WARN - go-linter - Run error: level=error msg="Running error: context loading failed: failed to load packages: failed to load with go/packages: err: exit status 2: stderr: panic: internal error: rs.graph is unexpectedly nil with -mod=vendor

goroutine 1 [running]:
cmd/go/internal/modload.updatePrunedRoots({0x15387d8, 0xc000018040}, 0xe6e75b?, 0xc00005a230, {0xc0000060a8, 0x1, 0x0?}, {0x0, 0x0, 0x0}, ...)
    c:/go/src/cmd/go/internal/modload/buildlist.go:955 +0xb6f
cmd/go/internal/modload.updateRoots({0x15387d8?, 0xc000018040?}, 0xe6d805?, 0x0?, {0xc0000060a8?, 0x0?, 0xc0000887b0?}, {0x0, 0x0, 0x0}, ...)
    c:/go/src/cmd/go/internal/modload/buildlist.go:653 +0xb7
cmd/go/internal/modload.(*loader).updateRequirements(0xc00012c000, {0x15387d8, 0xc000018040})
    c:/go/src/cmd/go/internal/modload/load.go:1361 +0x2a5
cmd/go/internal/modload.loadFromRoots({0x15387d8, 0xc000018040}, {{{0x0, 0x0}, 0xc000101020, 0x0, {0x0, 0x0}, 0x0, 0x1, ...}, ...})
    c:/go/src/cmd/go/internal/modload/load.go:1096 +0x70f
cmd/go/internal/modload.LoadPackages({0x15387d8?, 0xc000018040}, {{0x0, 0x0}, 0xc000101020, 0x0, {0x0, 0x0}, 0x0, 0x1, ...}, ...)
    c:/go/src/cmd/go/internal/modload/load.go:343 +0x308
cmd/go/internal/load.PackagesAndErrors({0x15387d8?, 0xc000018040?}, {0x27?, 0x0?, 0x0?, 0x0?}, {0xc00008e060, 0x1, 0x2})
    c:/go/src/cmd/go/internal/load/pkg.go:2704 +0x1cb
cmd/go/internal/list.runList({0x15387d8?, 0xc000018040}, 0xc000020f18?, {0xc00008e060?, 0x1, 0x2})
    c:/go/src/cmd/go/internal/list/list.go:508 +0xa05
main.invoke(0x180d9e0, {0xc00008e010, 0x6, 0x7})
    c:/go/src/cmd/go/main.go:218 +0x2ee
main.main()
    c:/go/src/cmd/go/main.go:175 +0x76e\n"
. Please make sure the project has no syntax error.

2022-09-05 12:25:50,557 [1863158]   WARN - go-linter - Debug command: cd C:\Users\..user..\Dev\src\..top folder..\..project folder.. && set "PATH=C:\Program Files\Go\bin;C:\WINDOWS\system32;C:\WINDOWS;..snip..;C:\Program Files\Go\bin;C:\Program Files\Git\cmd;C:\Users\..user..\AppData\Local\Microsoft\WindowsApps;C:\Users\..user..\go\bin;C:\Users\..user..\Dev\bin;" && set "GOPATH=C:\Users\..user..\Dev;C:\Users\..user..\Dev;C:\Users\..user..\Dev" && set "GO111MODULE=on" && "C:\Users\..user..\Dev\bin\golangci-lint.exe" "run" "--out-format" "json" "--allow-parallel-runners" "-j" "4" "--issues-exit-code" "1" "--max-issues-per-linter" "0" "--max-same-issues" "0" "-c" "C:\Users\..user..\Dev\src\..top folder..\..project folder..\.golangci.yml" "processing"

I notice that the plugin seems to be setting GO111MODULE=on??

xxpxxxxp commented 2 years ago

Hi @chrisnappin , yes the plugin explicitly set GO111MODULE=on if

So if you don't need go module on, please consider disabling those 2 places.

chrisnappin commented 2 years ago

Yes, we have those settings off. GO111MODULE=off is set as a global environment variable, and "Enable Go modules integration" is disabled in the GoLand IDE for each project we setup. However the plugin doesn't pick this up and doesn't work. I've restarted GoLand as a whole several times?

chrisnappin commented 2 years ago

If I run "go env" in a GoLand terminal window it also reports "GO111MODULE=off" so I am confident the global environment variable is set.

Our code builds in GoLand, so I am confident the "Enable Go modules integration" option is disabled, because without that GoLand doesn't compile our imports properly.

xxpxxxxp commented 2 years ago

thanks, seems a bug, checking

xxpxxxxp commented 2 years ago

Hi @chrisnappin , does the latest release fixed this problem?

chrisnappin commented 2 years ago

Brilliant, yes @xxpxxxxp this issue is now resolved in the v1.6.1 release.

Many thanks for the prompt fix, we're now able to use the plugin!