Go importer doesn't know MODULE/vX.Y version tags

  • Open
  • quality assurance status badge
Details
2 participants
  • Timo Wilken
  • Simon Tournier
Owner
unassigned
Submitted by
Timo Wilken
Severity
normal
T
T
Timo Wilken wrote on 21 Apr 2023 19:39
(address . bug-guix@gnu.org)
CS2M99VHXHVN.WOF38A5PXLE9@lap.twilken.net
Some Golang repositories apparently use a tagging scheme where each
submodule in the repo gets its own tags.

In this case, the example is cloud.google.com/go and its submodules

For example, for the cloud.google.com/go/longrunning submodule at
version 0.4.1, the Go importer should look for a tag called
"refs/tags/longrunning/v0.4.1" in the Git repository.

#+begin_example
$ guix import go -r cloud.google.com/go/longrunning
Backtrace:
19 (primitive-load "/home/timo/.config/guix/current/bin/gu…")
In guix/ui.scm:
2300:7 18 (run-guix . _)
2263:10 17 (run-guix-command _ . _)
In guix/scripts/import.scm:
89:11 16 (guix-import . _)
In ice-9/boot-9.scm:
1752:10 15 (with-exception-handler _ _ #:unwind? _ # _)
In guix/scripts/import/go.scm:
114:22 14 (_)
In guix/import/utils.scm:
638:27 13 (recursive-import _ #:repo->guix-package _ #:guix-name . #)
630:33 12 (lookup-node "cloud.google.com/go/longrunning" #f)
In guix/memoization.scm:
98:0 11 (mproc "cloud.google.com/go/longrunning" # #<procedure…> …)
In unknown file:
10 (_ #<procedure 7fb3e173c820 at guix/memoization.scm:17…> …)
In guix/import/go.scm:
685:10 9 (_ _ #:version _ #:repo _)
In ice-9/exceptions.scm:
406:15 8 (go-module->guix-package* . _)
In ice-9/boot-9.scm:
1752:10 7 (with-exception-handler _ _ #:unwind? _ # _)
In guix/import/go.scm:
511:19 6 (go-module->guix-package "cloud.google.com/go/longrunn…" …)
In guix/git.scm:
291:4 5 (update-cached-checkout _ #:ref _ #:recursive? _ # _ # _ …)
277:19 4 (resolve _)
In git/reference.scm:
60:8 3 (_ _ _)
In git/bindings.scm:
77:2 2 (raise-git-error _)
In ice-9/boot-9.scm:
1685:16 1 (raise-exception _ #:continuable? _)
1683:16 0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1683:16: In procedure raise-exception:
Git error: reference 'refs/tags/v0.4.1' not found
#+end_example

The same is true for other modules, e.g.
github.com/Azure/azure-sdk-for-go/sdk/internal, where the tag is
called "refs/tags/sdk/internal/v1.3.0" instead:

#+begin_example
$ guix import go -r github.com/Azure/azure-sdk-for-go/sdk/internal
Backtrace:
19 (primitive-load "/home/timo/.config/guix/current/bin/gu…")
In guix/ui.scm:
2300:7 18 (run-guix . _)
2263:10 17 (run-guix-command _ . _)
In guix/scripts/import.scm:
89:11 16 (guix-import . _)
In ice-9/boot-9.scm:
1752:10 15 (with-exception-handler _ _ #:unwind? _ # _)
In guix/scripts/import/go.scm:
114:22 14 (_)
In guix/import/utils.scm:
638:27 13 (recursive-import _ #:repo->guix-package _ #:guix-name . #)
630:33 12 (lookup-node "github.com/Azure/azure-sdk-for-go/sdk/in…" …)
In guix/memoization.scm:
98:0 11 (mproc "github.com/Azure/azure-sdk-for-go/sdk/internal" …)
In unknown file:
10 (_ #<procedure 7fa449ec0300 at guix/memoization.scm:17…> …)
In guix/import/go.scm:
685:10 9 (_ _ #:version _ #:repo _)
In ice-9/exceptions.scm:
406:15 8 (go-module->guix-package* . _)
In ice-9/boot-9.scm:
1752:10 7 (with-exception-handler _ _ #:unwind? _ # _)
In guix/import/go.scm:
511:19 6 (go-module->guix-package "github.com/Azure/azure-sdk-f…" …)
In guix/git.scm:
291:4 5 (update-cached-checkout _ #:ref _ #:recursive? _ # _ # _ …)
277:19 4 (resolve _)
In git/reference.scm:
60:8 3 (_ _ _)
In git/bindings.scm:
77:2 2 (raise-git-error _)
In ice-9/boot-9.scm:
1685:16 1 (raise-exception _ #:continuable? _)
1683:16 0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1683:16: In procedure raise-exception:
Git error: reference 'refs/tags/v1.3.0' not found
#+end_example
T
T
Timo Wilken wrote on 17 Jun 2023 17:12
Re: bug#63631: [PATCH] import: go: Handle subpackage versioning correctly.
(name . Ludovic Courtès)(address . ludo@gnu.org)
CTF06XBYWPT0.1MV6QA1B2OB98@lap.twilken.net
Hi Ludo', (hi everyone,)

On Wed Jun 14, 2023 at 11:09 PM CEST, Ludovic Courtès wrote:
Toggle quote (11 lines)
> Timo Wilken <guix@twilken.net> skribis:
> > Here's a patch that fixes the reported issue (bug#54097) for me. I've only
> > tested this on the github.com/googleapis/google-cloud-go/compute package so
> > far, though it seems to work there. Perhaps others have more testcases?
> >
> > I don't know enough about Go tooling to use it, so I've just patched the Guile
> > logic of the importer. (I don't write Go, I just want to package stuff written
> > in it.) In terms of performance, at least the repo contents are apparently
> > cached by the first `git-checkout-hash' call, even if it fails, so the second
> > call doesn't have to redownload them.

I've been testing my patch further this weekend, and I have a couple more
patches in the pipeline; I suppose I ought to clean those up and submit them.

In particular, I've got fixes for the following queued up locally:

1. Finding the `module-path-subdir' needs another case for e.g.
cloud.google.com/go/*.

2. My patch sometimes generates an unnecessary `go-version->git-ref' call.

3. Go versions need to be parsed from go.mod, since some packages require a
newer Go compiler than our default. This I've got a patch for, but this Go
version also ought to propagate up the dependency tree. I haven't found an
easy way to do that, since the importer seems to generate top-level
packages first, before descending the dep tree...

4. `fetch-module-meta-data' ought to ignore 4xx HTTP errors to follow the
spec; gonum.org/v1/gonum specifically depends on this behaviour.

I've been trying to recursively import github.com/matrix-org/dendrite, which
has a particularly large and hairy dependency tree. While I can now import it
without crashes, I can't build it from the imported package definitions yet --
mainly because of lots of dependency cycles in the generated packages, but
there may be more issues hidden beneath that.

Still, I can recommend it as a test of everyone's importer patches, since
it'll find a lot of edge cases in importing alone!

Toggle quote (3 lines)
> What you propose looks similar to part of the work Simon Tournier
> submitted at <https://issues.guix.gnu.org/63647>.

It seems lots of people have been working on the same problem -- in addition
to Simon's patches, I found a patch submitted by Elbek (issues 64035 & 64036;
Cc'd). I also forgot about the issue I submitted months ago (63001)...

Toggle quote (2 lines)
> What would you suggest? Simon?

Here's a brief comparison between Simon's patches and mine -- Simon's seem to
contain fixes for a couple more things than mine currently does:

1. Simon sorts available versions in an error message; this can presumably be
merged independently since it doesn't conflict with other patches.

2. Simon always prepends a "SUBDIR/" prefix to the tag if found, whereas I try
to find the plain "vX" tag first, then fall back to "SUBDIR/vX". Judging by
https://go.dev/ref/mod#vcs-version,Simon's approach seems more correct.
I'll change my implementation to match and try it out.

3. For detecting the `module-path-subdirectory' in Simon's patches: that's the
same approach I used initially, but I found I have to try `(substring
module-path (string-length import-prefix))' first (to handle e.g.
cloud.google.com/go/*). This is one of the things I haven't submitted
yet...

Toggle quote (2 lines)
> Thanks for the patch, Timo!

Thanks for your work in sorting through all of this, Ludo'!

Cheers,
Timo
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEU+w8BoVog92SNVvCL8eFBGgfabAFAmSNzaUACgkQL8eFBGgf
abDEaA//Y6k/Uckhvq+wllES0TjACxVG+2bY2E/wLZNoQShXF5Tn3ZQ9o2HOU7Gr
p8er/t/JkPLYm9w2MidUtvTms6qxp8H/YIZ12gzZ+GP/eoKa/iiqt42+KZvLS/Is
B2JWEcaJLFYy0w9nuubeuQpgcWEmxyk7/zb++GovD0tfYgczII3N1Z5fhRmeAj0N
FbKqfkBocxruYvBfcI5KhMV6Q1TjCwuAH+j2iwNmsiSnm7NTKbJxfCyO9+p5UF9w
O/em01p9J+Cg6EEFunwoi1pjoEAkVZCRtgaiP1SMgapq74UKKagvsWqMoW+JHpDf
uuiaVn1sLuTt+u9KGamYqaCj1NRcCfN7SjPxS7oTM4hsytVDmUB/eIHD6t3HntCP
Ev43fJKJwLoybQV0ptajnJggEEaEY1cegQG683jsD0ycrToh4YEhLe5fQsGhaLMA
7MSLjjf0K73BoFyZi+wYyfDPYqXRQmpb3Z6cKJPlF3v4IF13UtSxP0yBRdz930aI
1b1Q5khLQzQBI0fvxMNcZGPeA2RjPyNsXE8pKn9zEkIunzX9VYN8az++EjX928Ox
mmgjEUsLWMPCSMwGcEoZye6R5wJUG34LEkoQTbySf+314hlELPuGcLCatFgZZbXq
1Hn1upt13XYRYVCX/SXIpBJL9gdNbi2sSg8FVm4Aq+sQQqZzAKs=
=fjJn
-----END PGP SIGNATURE-----


S
S
Simon Tournier wrote on 16 Aug 2023 17:59
Re: bug#63001: bug#63631: [PATCH] import: go: Handle subpackage versioning correctly.
875y5ff05i.fsf@gmail.com
Hi Timo,

On Sat, 17 Jun 2023 at 17:12, "Timo Wilken" <guix@twilken.net> wrote:

Toggle quote (19 lines)
>> What would you suggest? Simon?
>
> Here's a brief comparison between Simon's patches and mine -- Simon's seem to
> contain fixes for a couple more things than mine currently does:
>
> 1. Simon sorts available versions in an error message; this can presumably be
> merged independently since it doesn't conflict with other patches.
>
> 2. Simon always prepends a "SUBDIR/" prefix to the tag if found, whereas I try
> to find the plain "vX" tag first, then fall back to "SUBDIR/vX". Judging by
> https://go.dev/ref/mod#vcs-version, Simon's approach seems more correct.
> I'll change my implementation to match and try it out.
>
> 3. For detecting the `module-path-subdirectory' in Simon's patches: that's the
> same approach I used initially, but I found I have to try `(substring
> module-path (string-length import-prefix))' first (to handle e.g.
> cloud.google.com/go/*). This is one of the things I haven't submitted
> yet...

Sorry if I have missed some patches or overlooked something. Do you
plan to send another patch series handling all?


Cheers,
simon
?