Bug 244783 - lang/go: Updating ports to go 1.14 can cause vendor version errors (eg: net-p2p/bitmark)
Summary: lang/go: Updating ports to go 1.14 can cause vendor version errors (eg: net-p...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Julien Laffaye
URL: https://reviews.freebsd.org/D24122
Keywords: needs-qa
Depends on:
Blocks: 244881 244891
  Show dependency treegraph
 
Reported: 2020-03-13 05:25 UTC by Christopher Hall
Modified: 2020-04-03 13:01 UTC (History)
4 users (show)

See Also:
koobs: maintainer-feedback? (jlaffaye)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Hall 2020-03-13 05:25:37 UTC
Ff the source repo has a go.mod file containing:

  go 1.14

There will be lots of errors because go 1.14 does more strict version checking

Sample errors:

    golang.org/x/crypto@v0.0.0-20200311171314-f7b00557c8c4: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
    golang.org/x/sync@v0.0.0-20190423024810-112230192c58: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
    golang.org/x/time@v0.0.0-20191024005414-555d28b269f0: 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
    *** Error code 1


A workaround is to add a files/patch-go.mod changing the 1.14 to 1.13 to restore the earlier go behaviour.
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2020-03-13 05:36:35 UTC
Thank you for your report Christopher

Can you provide an example list of ports that are affected?
Comment 2 Christopher Hall 2020-03-13 07:08:03 UTC
currently only affects mine, I was just trying test build it before I created a review  to upgrade it.  So I do not think this affect any of the current go ports as they are all likely to be cointain "go 1.13" in their mod files
Comment 3 Christopher Hall 2020-03-13 07:26:47 UTC
you can see the WIP version here: https://github.com/bitmark-inc/bitmarkd-ports/tree/master/FreeBSD/net-p2p/bitmark

This built because this version patches the go.mod.
So "rm files/patch-go.mod" should give you the same build errors I have with go-1.14_1,1
Comment 4 Dmitri Goutnik freebsd_committer freebsd_triage 2020-03-13 13:27:54 UTC
This looks like it could be a serious issue as more upstreams will be updating go.mod to require go1.14:

"When -mod=vendor is set (explicitly or by default), the go command now verifies that the main module's vendor/modules.txt file is consistent with its go.mod file." [1]

Because -mod=vendor is the only mode that works for ports due to restricted network access and there's no way to generate vendor/modules.txt during port build, the options we have seem to be

(a) keep generated vendor/modules.txt in files/ and copy it over to ${WRKSRC}/vendor before build
(b) patch go.mod go version back to 1.13 (probably could be automated with go.mk)
(c) patch lang/go [2] to skip these consistency checks

[1] https://golang.org/doc/go1.14#go-command
[2] https://github.com/golang/go/blob/9d67a94217c0a46a2b02a1fc67bb3e436dac0c97/src/cmd/go/internal/modload/vendor.go#L135
Comment 6 commit-hook freebsd_committer freebsd_triage 2020-04-02 17:36:40 UTC
A commit references this bug:

Author: dmgk
Date: Thu Apr  2 17:29:18 UTC 2020
New revision: 530387
URL: https://svnweb.freebsd.org/changeset/ports/530387

Log:
  lang/go: relax module consistency checks if vendor/modules.txt is missing

  Starting from go1.14, go verifies that vendor/modules.txt matches the
  requirements and replacements listed in the main module go.mod file, and it is
  a hard failure if vendor/modules.txt is missing.

  Relax module consistency checks and switch back to pre go1.14 behaviour if
  vendor/modules.txt is missing and GO_NO_VENDOR_CHECKS=1 is set in the
  environment regardless of go version requirement in go.mod.

  Upstream PR: https://github.com/golang/go/issues/37948

  PR:		244783
  Reported by:	Christopher Hall <hsw@bitmark.com>
  Reviewed by:	mikael swills yuri
  Approved by:	jlaffaye (maintainer timeout, 2 weeks)
  MFH:		2020Q2
  Differential Revision:	https://reviews.freebsd.org/D24122

Changes:
  head/lang/go/Makefile
  head/lang/go/files/
  head/lang/go/files/patch-src_cmd_go_internal_modload_init.go
Comment 7 commit-hook freebsd_committer freebsd_triage 2020-04-02 17:56:43 UTC
A commit references this bug:

Author: dmgk
Date: Thu Apr  2 17:39:15 UTC 2020
New revision: 530388
URL: https://svnweb.freebsd.org/changeset/ports/530388

Log:
  Mk/Uses/go.mk: Set GO_NO_VENDOR_CHECKS=1

  Set GO_NO_VENDOR_CHECKS=1 to signal lang/go to relax vendor checks during ports
  build.

  PR:		244783
  Reported by:	Christopher Hall <hsw@bitmark.com>
  Reviewed by:	mikael swills yuri
  MFH:		2020Q2
  Differential Revision:	https://reviews.freebsd.org/D24122

Changes:
  head/Mk/Uses/go.mk
Comment 8 commit-hook freebsd_committer freebsd_triage 2020-04-03 12:52:12 UTC
A commit references this bug:

Author: dmgk
Date: Fri Apr  3 12:51:25 UTC 2020
New revision: 530488
URL: https://svnweb.freebsd.org/changeset/ports/530488

Log:
  MFH: r530387

  lang/go: relax module consistency checks if vendor/modules.txt is missing

  Starting from go1.14, go verifies that vendor/modules.txt matches the
  requirements and replacements listed in the main module go.mod file, and it is
  a hard failure if vendor/modules.txt is missing.

  Relax module consistency checks and switch back to pre go1.14 behaviour if
  vendor/modules.txt is missing and GO_NO_VENDOR_CHECKS=1 is set in the
  environment regardless of go version requirement in go.mod.

  Upstream PR: https://github.com/golang/go/issues/37948

  PR:		244783
  Reported by:	Christopher Hall <hsw@bitmark.com>
  Reviewed by:	mikael swills yuri
  Approved by:	jlaffaye (maintainer timeout, 2 weeks)
  Differential Revision:	https://reviews.freebsd.org/D24122

  Approved by:	ports-secteam (joneum)

Changes:
_U  branches/2020Q2/
  branches/2020Q2/lang/go/Makefile
  branches/2020Q2/lang/go/files/
Comment 9 commit-hook freebsd_committer freebsd_triage 2020-04-03 13:01:15 UTC
A commit references this bug:

Author: dmgk
Date: Fri Apr  3 12:53:12 UTC 2020
New revision: 530489
URL: https://svnweb.freebsd.org/changeset/ports/530489

Log:
  MFH: r530388

  Mk/Uses/go.mk: Set GO_NO_VENDOR_CHECKS=1

  Set GO_NO_VENDOR_CHECKS=1 to signal lang/go to relax vendor checks during ports
  build.

  PR:		244783
  Reported by:	Christopher Hall <hsw@bitmark.com>
  Reviewed by:	mikael swills yuri
  Differential Revision:	https://reviews.freebsd.org/D24122

  Approved by:	ports-secteam (joneum)

Changes:
_U  branches/2020Q2/
  branches/2020Q2/Mk/Uses/go.mk