🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.bugs.rc
Article #2551

Bug#1153300: dh-go: 1.70 writes a replace next to the use for the same module, FTBFS

#2551
From: juan.mendezr
Date: Sat, 07 Nov 2026 00:40
107 lines
5837 bytes
Package: dh-go
Version: 1.70
Severity: serious
Tags: patch
X-Debbugs-Cc: juan.mendezr@proton.me

1.70 cannot build a multi-module package when that package's own -dev is also
installed under /usr/share/gocode/src. That is the case in autopkgtest for
every package, and in a plain build for a package whose build dependencies
pull its own -dev back in. otel is in the second group: it build depends on
golang-google-grpc-dev, which depends on golang-opentelemetry-otel-dev, and
dh-go says so during configure, "go.opentelemetry.io/otel is already
installed. Please check for circular dependencies."

golang-opentelemetry-otel 1.46.0-3, unchanged source that is in testing, in a
clean sid chroot with the 1.70 from the mirror:

  go: workspace module go.opentelemetry.io/otel/sdk/metric is replaced at all
      versions in the go.work file. To fix, remove the replacement from the
      go.work file or specify the version at which to replace the module.
  dh_auto_build: error: cd _build && go install -trimpath -v -p 24 returned
      exit code 1

44 errors, 22 distinct modules, every one of them in the package's own
DH_GOLANG_BUILDPKG. This is a plain build, not autopkgtest.

The same log carries 20460 copies of

  Use of uninitialized value $_ in string eq at
    /usr/share/perl5/Debian/Debhelper/Buildsystem/golang.pm line 1051

Line 1051 is the skip that 1.70 changed:

  -    next if grep { $_ eq $module } @targets;
  +    next if grep { $_ eq $module } @use_modules;

@use_modules is all undef by then. It is wiped twelve lines above, at line 1000:

  @deps_to_check = map { $this->_get_go_module_dependencies($_) } @use_modules;

In map, $_ is an alias to the array element. _get_go_module_dependencies reads
go.mod with an unlocalised "while (<$gomod>)", which assigns to the global $_,
so every call overwrites the element it was passed and leaves undef there at
EOF. The grep then matches nothing, each module in the workspace also gets a
replace, and go refuses the workspace.

Reproducer without dh-go:

  sub reads_a_file {
      open(my $fh, "<", "/etc/hostname") or die $!;
      while (<$fh>) { }
      return ("dep");
  }
  my @use_modules = ("mod/a", "mod/b", "mod/c");
  my @deps = map { reads_a_file($_) } @use_modules;
  # @use_modules is now (undef, undef, undef)
  # grep { $_ eq "mod/a" } @use_modules finds nothing

1.69 was not affected because @targets never passes through that map. The
change at 1051 is correct in itself, it just landed on top of this.

Fix, in _get_go_module_dependencies, before the loop that reads go.mod, also
sent as https://salsa.debian.org/go-team/dh-go/-/merge_requests/10 :

  --- a/lib/Debian/Debhelper/Buildsystem/golang.pm
  +++ b/lib/Debian/Debhelper/Buildsystem/golang.pm
  @@
       open(my $gomod, "<", $gomodfile)
         or error("failed to read $gomodfile: $!");
  +    local $_;
       while (<$gomod>) {

Built as 1.70+fix1 and used to rebuild the same otel source in a clean sid
chroot: Status successful, Lintian successful, Autopkgtest pass, 125 tests in
the build and 125 in the autopkgtest, no failures. The 20460 warnings and the
44 workspace errors are gone. Without the patch the same .dsc and the same
chroot recipe fail at dh_auto_build.

A lexical loop variable would be better style and would remove the hazard for
good, but it means touching the regexes in the loop body, so this is the
smaller change for unstable. The same pattern is in build(), which is not
called from a map today.

Second package, from another testbed and not my own run: the collector sees
the same thing from the autopkgtest side, 166 "is replaced at all versions"
and 33367 uninitialized value warnings, with dh-go 1.70 in the testbed. Its
plain build passes, because nothing pulls its own -dev into the build chroot.
https://salsa.debian.org/mendezr/golang-opentelemetry-collector/-/pipelines/1207763

Severity serious because it is an FTBFS in unstable for packages that build
today, and the dh-go migration excuses currently list about 50 reverse
dependency autopkgtests.
Technical Details
Message-ID: <NWCDn-aiiU-3@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!srl.newsdeef.eu!news.corradoroberto.it!news.servidellagleba.it!bofh.it!news.nic.it!robomod

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!srl.newsdeef.eu!news.corradoroberto.it!news.servidellagleba.it!bofh.it!news.nic.it!robomod
From: juan.mendezr@proton.me
Newsgroups: linux.debian.bugs.rc
Subject: Bug#1153300: dh-go: 1.70 writes a replace next to the use for the same module, FTBFS
Date: Sat, 07 Nov 2026 01:40:01 +0100
Message-ID: <NWCDn-aiiU-3@gated-at.bofh.it>
X-Original-To: submit@bugs.debian.org
X-Mailbox-Line: From debian-bugs-rc-request@lists.debian.org  Sat Nov  7 00:35:07 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: -1.44
Reply-To: juan.mendezr@proton.me, 1153300@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: juan.mendezr@proton.me, team+pkg-go@tracker.debian.org
X-Debian-Pr-Message: report 1153300
X-Debian-Pr-Package: dh-go
X-Debian-Pr-Keywords: patch
X-Debian-Pr-Source: dh-go
Feedback-ID: 176548819:user:proton
X-Pm-Message-ID: d4934c2c6c11904aa871e0c93bb26dd97e4117c6
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-rc@lists.debian.org> archive/latest/837432
List-ID: <debian-bugs-rc.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-rc/>
Approved: robomod@news.nic.it
Lines: 107
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Sat, 07 Nov 2026 00:32:36 +0000
X-Original-Message-ID: <c8840e8a8c9803d838c1caa44cd7e0d7@proton.me>