vc60er / deptree

show golang dependence like tree
76 stars 9 forks source link

exit status 1, go: updates to go.sum needed, disabled by -mod=readonly #15

Open jaronnie opened 12 months ago

jaronnie commented 12 months ago

$ go mod graph | deptree -d 2 -t -a call 'go list -u -m -json all', be patient... 2023/07/14 10:48:35 exit status 1, go: updates to go.sum needed, disabled by -mod=readonly

gen2thomas commented 11 months ago

Hi @jaronnie , please can yo provide some more information, e.g. on which project do you have run the provided command line, your OS and also your Go version.

Thanks Thomas

Grekkq commented 3 months ago

Hi @gen2thomas, also encountered this bug. I believe it started to appear after switching from Go v1.19 to v1.21 when trying to run deptree in any project that uses go mod vendor. It can be solved by adding -mod=readonly or -mod=mod to the go list command. When running in a project that uses vendor directory the problematic command go list -u -m -json all, prints:

go: can't determine available upgrades using the vendor directory
        (Use -mod=mod or -mod=readonly to bypass.)

After applying the fix with either go list -mod=readonly -u -m -json all or go list -mod=mod -u -m -json all we get the expected output with package list. Above outputs were generated using go version go1.21.5 darwin/arm64