Bug 258474 - Framework: go modules fetch fails when pkg is not installed
Summary: Framework: go modules fetch fails when pkg is not installed
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: Dmitri Goutnik
URL: https://reviews.freebsd.org/D35145
Depends on:
Reported: 2021-09-13 09:18 UTC by Franco Fichtner
Modified: 2022-05-13 18:41 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (girgen)

pkg dependency (521 bytes, patch)
2021-09-13 09:18 UTC, Franco Fichtner
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Franco Fichtner 2021-09-13 09:18:15 UTC
Created attachment 227870 [details]
pkg dependency


Probably not the right fix, but when FETCH_DEPENDS tries to install go it fails with missing pkg-static.  This is a workaround/POC that can be used to make it continue.

Noticed when trying to fetch distfiles for net-mgmt/telegraf in a clean jail since go:modules was added there.

Comment 1 Franco Fichtner 2022-04-26 09:21:51 UTC
Please reassign, easy fix.
Comment 2 Dmitri Goutnik freebsd_committer 2022-05-05 22:17:19 UTC

I just tested this on a fresh installation of 12.3-RELEASE. The first thing make does is pull freebsd-pkg-1.17.2_GH0.tar.gz and start building it, so it appears there's not need to add a dependency on pkg.

Perhaps something is missing in jail?
Comment 3 Franco Fichtner 2022-05-06 06:02:36 UTC
After you remove all packages and remove distfiles, go to net-mgmt/telegraf and type "make fetch". It will only fetch go and build it, but install will fail which in turn leads to not fetching telegraf distfiles because go is needed but cannot be installed.

Comment 4 Dmitri Goutnik freebsd_committer 2022-05-06 11:27:51 UTC
`make fetch` also starts by fetching freebsd-pkg-1.17.2_GH0.tar.gz on my install. What does `make all-depends-list` say? Is CLEAN_FETCH_ENV defined?
Comment 5 Franco Fichtner 2022-05-06 11:36:55 UTC
Nice catch, CLEAN_FETCH_ENV use seems to be it dating back to 2016... https://github.com/opnsense/tools/commit/7c007d7bb55

Is this to be considered "working as intended"? I understand the mechanics but seems like it's sabotaging itself then.

Comment 6 Dmitri Goutnik freebsd_committer 2022-05-06 11:45:21 UTC
I'm not sure why OPNsense insists on having CLEAN_FETCH_ENV set, but it appears to not be compatible with GO_MODULE.
Comment 7 Franco Fichtner 2022-05-06 11:48:53 UTC
Well the idea is a fetch stage that isn't tainted with package builds at all (could always produce unnecessary errors) but GO_MODULE would leave this concept behind anyway. Stuffing package dependency in there or blocking fetch when CLEAN_FETCH_ENV is set would both be useful changes. What would you prefer?
Comment 8 Dmitri Goutnik freebsd_committer 2022-05-06 12:00:26 UTC
Blocking fetch with a message that CLEAN_FETCH_ENV is defined seems cleaner to me. I'll look into it, thanks for the report.
Comment 9 Franco Fichtner 2022-05-06 12:02:24 UTC
Fair enough, thanks for the help. I will revisit CLEAN_FETCH_ENV use locally then.

Comment 10 commit-hook freebsd_committer 2022-05-13 18:40:38 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d71b4ca7752864918dea9b92e7f65c15deb3d290

commit d71b4ca7752864918dea9b92e7f65c15deb3d290
Author:     Dmitri Goutnik <dmgk@FreeBSD.org>
AuthorDate: 2022-05-13 18:34:15 +0000
Commit:     Dmitri Goutnik <dmgk@FreeBSD.org>
CommitDate: 2022-05-13 18:38:01 +0000

    Mk/Uses/go.mk: Block modules download when CLEAN_FETCH_ENV is defined

    Additionally, stop overriding post-fetch and post-extract targets.

    PR:             258474
    Differential Revision:  https://reviews.freebsd.org/D35145

 Mk/Uses/go.mk | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)