openSUSE / obs-service-go_modules

OBS Source Service to download, verify, and vendor Go module dependency sources
GNU General Public License v2.0
19 stars 18 forks source link

vendor/modules.txt created, but apparently not correct #4

Closed johanneskastl closed 4 years ago

johanneskastl commented 4 years ago

Hi all,

not sure which part is to blame for that, but when trying to build https://github.com/mattn/go-ieproxy using obs-service-go_modules, I get a modules.txt that go does not like:

[    3s] + mkdir -p /home/abuild/rpmbuild/BUILDROOT/golang-github-mattn-go-ieproxy-0.0.1.unreleased-0.x86_64/usr/bin
[    3s] + go build -mod=vendor -buildmode=pie
[    3s] go: inconsistent vendoring in /home/abuild/rpmbuild/BUILD/go-ieproxy-0.0.1.unreleased:
[    3s]        golang.org/x/net@v0.0.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
[    3s]        golang.org/x/sys@v0.0.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
[    3s]        golang.org/x/text@v0.3.2: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
[    3s]
[    3s] run 'go mod vendor' to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory

The modules.txt looks like this:

# golang.org/x/net v0.0.0-20191112182307-2180aed22343
## explicit
golang.org/x/net/http/httpproxy
golang.org/x/net/idna
# golang.org/x/sys v0.0.0-20191112214154-59a1497f0cea
## explicit
golang.org/x/sys/windows
golang.org/x/sys/windows/registry
# golang.org/x/text v0.3.2
## explicit
golang.org/x/text/secure/bidirule
golang.org/x/text/transform
golang.org/x/text/unicode/bidi
golang.org/x/text/unicode/norm

The state I got this error with can be found here: https://build.opensuse.org/package/rdiff/home:ojkastl_buildservice:branches:devel:languages:go/golang-github-mattn-go-ieproxy?linkrev=base&rev=4

jfkw commented 4 years ago

Which buildlog in the OBS project shows the error above? I would like to see which version of go is used during the build. I think the option mod=vendor is not recognized in this version.

johanneskastl commented 4 years ago

This one for example: https://build.opensuse.org/package/live_build_log/home:ojkastl_buildservice:branches:devel:languages:go/golang-github-mattn-go-ieproxy/SLE_15_SP1/x86_64

[   61s] go1.14-1.14-1.1                       ########################################
[   62s] update-alternatives: using /usr/lib64/go/1.14/bin/go to provide /usr/bin/go (go) in auto mode

I tried to nail down a recent go1.14 version using this stanza in the spec:

BuildRequires:  (go >= 1.14 with go < 1.15)
jfkw commented 4 years ago

I see, thanks for documenting your method of pinning the Go version used. It may be that the step osc service disabledrun run locally is using an earlier version of go to produce the vendor/modules.txt and during the build phase in OBS is using the pinned go1.14.

Thanks for bringing this potential version mismatch to my attention, I will look into the issue with upstream Go.

johanneskastl commented 4 years ago

When I installed the obs-service-go_modules on my laptop, it pulled in the go1.14 version, too, so I am not sure that there is a mismatch.

rpm -qf /usr/bin/go
go1.14-1.14-1.1.x86_64
jfkw commented 4 years ago

I see, so both are using go1.14. This is the error condition you are encountering it seems:

Before 1.14, modules.txt did not indicate whether modules were listed
explicitly in the main module's go.mod file.
However, we can at least detect a version mismatch if packages were
vendored from a non-matching version.

I think it would be helpful to see if this can be reproduced outside of OBS packaging, i.e. just run the go commands on a git clone of ieproxy.

johanneskastl commented 4 years ago

Sure.

/path/to/go-ieproxy (master)>go build \
>    -mod=vendor \
>    -buildmode=pie
go: inconsistent vendoring in /path/to/go-ieproxy:
        golang.org/x/net@v0.0.0-20191112182307-2180aed22343: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        golang.org/x/sys@v0.0.0-20191112214154-59a1497f0cea: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
        golang.org/x/text@v0.3.2: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

run 'go mod vendor' to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory
/path/to/go-ieproxy (master)>git show HEAD
commit 2dbc853185d9515cd0b7934cc7bfedab1565ac04 (HEAD -> master, origin/master, origin/HEAD)
Merge: 6d733ce 5ec61c8
Author: mattn <mattn.jp@gmail.com>
Date:   Mon Feb 3 13:04:49 2020 +0900

    Merge pull request #22 from KedarB/master

    Additional checks were added to toggle between the registry key LOCAL…

/path/to/go-ieproxy (master)>LANG=C git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
/path/to/go-ieproxy (master)>
jfkw commented 4 years ago

I can't reproduce the above:

/path/to/go-ieproxy> go version
go version go1.14 linux/amd64
/path/to/go-ieproxy> sudo rm -rf vendor/ ~/go/pkg/*  # to ensure a clean start

/path/to/go-ieproxy> go mod vendor
go: downloading golang.org/x/sys v0.0.0-20191112214154-59a1497f0cea
go: downloading golang.org/x/net v0.0.0-20191112182307-2180aed22343
go: downloading golang.org/x/text v0.3.2

/path/to/go-ieproxy> go mod verify
all modules verified

/path/to/go-ieproxy> go build -mod=vendor -buildmode=pie
( no action taken, need to target a package w a main() )

Anything you can think of that would be different on the two systems?

johanneskastl commented 4 years ago

Hi Jeff, I just tried again following your exact steps and cannot reproduce the error now, too.

Sorry, my bad.

johanneskastl commented 4 years ago

Funny, I just removed the vendor directory and extracted the vendor.tar.gz that I had created using the service. No both go mod verify and go build -mod=vendor -buildmode=pie do not show the error...

jfkw commented 4 years ago

Glad to hear it is working.

johanneskastl commented 4 years ago

Could it be that my spec file is missing some instructions to actually use the vendor.tar.gz?

jfkw commented 4 years ago

Closing, fixed. Discussing unrelated packaging issues offline.

johanneskastl commented 4 years ago

FYI, this issue was not a malformed modules.txt, but rather a missing modules.txt due to a missing instruction that the vendor.tar.gz should be used at all..

The following worked (the third line is the one that was actually missing):

%prep
%setup -q -n go-ieproxy-%{version}
%setup -q -T -D -a 1 -n go-ieproxy-%{version}