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

x/vgo: ziphash mismatch between different platform #26229

Closed
CJ-Jackson opened this issue Jul 5, 2018 · 6 comments

Comments

@CJ-Jackson
Copy link

commented Jul 5, 2018

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

version 1.10.3
vgo (6cd5a417451d8ee907692eded07ef1b6b53825b1)

Does this issue reproduce with the latest release?

Yes

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

Windows

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\ChristopherJohn\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\go
set GOPROXY=
set GORACE=
set GOROOT=C:\go
set GOTMPDIR=
set GOTOOLDIR=C:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\CHRIST~1\AppData\Local\Temp\go-build030288550=/tmp/go-build -gno-record-gcc-switches
set VGOMODROOT=D:\go\src\github.com\CJ-Jackson\siteCore

Linux

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/cjjackson/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/cjjackson/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build007184873=/tmp/go-build -gno-record-gcc-switches"
VGOMODROOT="/home/cjjackson/go/src/github.com/CJ-Jackson/siteCore"

What did you do?

Run vgo mod -sync

What did you expect to see?

ziphash to be consistent across different platform (e.g. Windows and Linux)

What did you see instead?

ziphash is not consistent between different platform.

Windows (github.com/cjtoolkit/validate@v1.1.0)

h1:xzZBYm2Zs8GdrEIMgGCDOxWPUO5cMy79lYhMKwgezT0=

Linux (github.com/cjtoolkit/validate@v1.1.0)

h1:b+yVXiNn6agp1sb2nFviiSDV/HLzS2JjCyamWfs5mmw=

Causes verification to fail while working with different platform.

@gopherbot gopherbot added this to the vgo milestone Jul 5, 2018

@rsc

This comment has been minimized.

Copy link
Contributor

commented Jul 6, 2018

Needless to say, that's not supposed to happen. On my Mac I get the same hash you do on Linux. Windows is the difference. We're using a bare Git repo and 'git archive', which I assumed never even wrote the individual files to disk, so I thought I wouldn't have to worry about line endings. (I'm assuming its line endings, but who knows?)

Can you please attach %GOPATH%\src\mod\cache\download\github.com\cjtoolkit\validate@v\v1.1.0.zip from your Windows system to this issue?

Thanks.

@CJ-Jackson

This comment has been minimized.

Copy link
Author

commented Jul 6, 2018

Here is the attachment, as requested!
v1.1.0.zip

I open up a *.go file from the archive in sublime on linux and windows, I can confirm that the line ending is different.

@CJ-Jackson

This comment has been minimized.

Copy link
Author

commented Jul 6, 2018

I got a potential fix here, replace the command

git archive

with

git -c core.eol=lf -c core.autocrlf=input archive

This should enforce the unix line ending, on any platform.

Update

On windows, in powershell I executed those commands

git config --global core.eol lf
git config --global core.autocrlf input

Deleted the mod folder, than ran vgo mod -sync and now the ziphash is matching linux perfectly.

I can confirm, the line ending was causing the issue.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Jul 6, 2018

@CJ-Jackson, thanks very much for identifying the right git flags. I'll apply that fix.

@gopherbot

This comment has been minimized.

Copy link

commented Jul 6, 2018

Change https://golang.org/cl/122480 mentions this issue: cmd/go/internal/modfetch/codehost: fix git code export on Windows

@CJ-Jackson

This comment has been minimized.

Copy link
Author

commented Jul 6, 2018

@rsc You're welcome!

@golang golang locked and limited conversation to collaborators Jul 12, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.