Skip to content
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

cmd/go: mod vendor modules.txt sort order is inconsitent between linux and freebsd #34538

Closed
pgier opened this issue Sep 25, 2019 · 6 comments
Closed
Labels
FrozenDueToAge help wanted modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@pgier
Copy link

pgier commented Sep 25, 2019

What version of Go are you using (go version)?

$ go version
go version go1.13 freebsd/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"                                                                                                                                                                   
GOARCH="amd64"                                                                           
GOBIN=""
GOCACHE="/home/ec2-user/.cache/go-build"
GOENV="/home/ec2-user/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="freebsd"
GONOPROXY=""
GONOSUMDB=""
GOOS="freebsd"
GOPATH="/home/ec2-user/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/home/ec2-user/go1.13"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/home/ec2-user/go1.13/pkg/tool/freebsd_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/home/ec2-user/go/src/github.com/prometheus/node_exporter/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 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build431750408=/tmp/go-build -gno-record-gcc-switches"
e

What did you do?

Ran go mod vendor on freebsd.

What did you expect to see?

vendor/modules.txt should not be modified

What did you see instead?

vendor/modules.txt was modified to sort in a different order from the committed version

@pgier
Copy link
Author

pgier commented Sep 25, 2019

Providing some more information here. There appears to be a difference in the sorting order of vendor/modules.txt between linux and freebsd.

Freebsd uses pure alpha ordering and linux takes the number of path components into account

 github.com/prometheus/procfs
 github.com/prometheus/procfs/bcache
+github.com/prometheus/procfs/internal/fs
+github.com/prometheus/procfs/internal/util
 github.com/prometheus/procfs/nfs
 github.com/prometheus/procfs/sysfs
 github.com/prometheus/procfs/xfs
-github.com/prometheus/procfs/internal/fs
-github.com/prometheus/procfs/internal/util

From the diff excerpt you can see that bsd is trying to sort procfs/internal before procfs/nfs. However, running on linux the procfs/internal packages are placed later, I'm guessing because there are 5 path components instead of 4.

@ALTree ALTree changed the title go mod vendor modules.txt sort order is inconsitent between linux and freebsd cmd/go: mod vendor modules.txt sort order is inconsitent between linux and freebsd Sep 26, 2019
@ALTree ALTree added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. modules labels Sep 26, 2019
@ALTree ALTree added this to the Go1.14 milestone Sep 26, 2019
@bcmills bcmills added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Sep 27, 2019
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 27, 2019
@bcmills
Copy link
Contributor

bcmills commented Sep 27, 2019

@pgier, want to send a fix? Should be a pretty easy one.
(https://golang.org/doc/contribute.html)

@pgier
Copy link
Author

pgier commented Sep 27, 2019

Yeah, I can git it a shot. Which way is the right behaviour? The bsd way (pure alpha) seems better to me because it would group together packages with their subpackages, but changing the linux version will probably affect more people, and I'm not sure if there is a specific reason it was done that way.

@bcmills
Copy link
Contributor

bcmills commented Sep 27, 2019

Probably we should sort lexically by path. (That is: use the same order that sort.Strings would produce for the paths.)

@pgier
Copy link
Author

pgier commented Sep 27, 2019

Testing this further it seem to be a difference between go 1.12 and 1.13. I had been using 1.12 on Linux when I thought I was using 1.13. Sorry for the faulty bug report!

@pgier pgier closed this as completed Sep 27, 2019
@bcmills
Copy link
Contributor

bcmills commented Sep 27, 2019

Oh, yep! There it is: https://golang.org/cl/174527.

@golang golang locked and limited conversation to collaborators Sep 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants