Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FTBFS due to usage of deprecated dependency #200

Closed
upils opened this issue Oct 12, 2023 · 3 comments
Closed

FTBFS due to usage of deprecated dependency #200

upils opened this issue Oct 12, 2023 · 3 comments
Assignees
Labels
Milestone

Comments

@upils
Copy link

upils commented Oct 12, 2023

dh-make-golang is failing to build from source. See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1043070

This is due to golang.org/x/tools/go/vcs being deprecated and removed from the tools pkg (see https://go-review.googlesource.com/c/tools/+/159818/4).

According to the aforementioned change, the recommended way is to use go list -json, which would require rewriting parts of the code.

Another solution would be to pin the version of golang-golang-x-tools to an older version. But in debian the previous stable version is 0.5.0 which is a bit old.

@anthonyfok anthonyfok self-assigned this Dec 1, 2023
@anthonyfok anthonyfok added the bug label Dec 1, 2023
@anthonyfok anthonyfok added this to the v0.7.0 milestone Dec 1, 2023
@anthonyfok
Copy link
Member

@upils Thank you so much for investigating this FTBFS and suggesting the use of go list -json as solution.

I hope I will have time to look at it soon, but probably not earlier than end of 2023.
If anyone else has the capacity, you are more than welcome to help fix this issue.

Many thanks!

@myhro
Copy link

myhro commented Dec 31, 2023

I debugged this issue today and it doesn't look like go list -json is a proper replacement for the golang.org/x/tools/go/vcs package. At least not for the functionality provided by vcs.RepoRootForImportPath(), which is used in multiple places.

Looking at the examples in the tests, it's not possible to figure, for instance, the repository root for the github.com/google/go-github/v38 module:

  1. By default it is treated as a package and can't be found:
$ go list -json github.com/google/go-github/v38
no required module provides package github.com/google/go-github/v38; to add it:
        go get github.com/google/go-github/v38
  1. Looking for the actual package (the one in the import statements) yields a bit more information, but none of that refers to the repository root:
$ go list -json github.com/google/go-github/v38/github | grep github.com
        "Dir": "/home/myhro/go/pkg/mod/github.com/google/go-github/v38@v38.1.0/github",
        "ImportPath": "github.com/google/go-github/v38/github",
        "Root": "/home/myhro/go/pkg/mod/github.com/google/go-github/v38@v38.1.0",
                "Path": "github.com/google/go-github/v38",
                "Dir": "/home/myhro/go/pkg/mod/github.com/google/go-github/v38@v38.1.0",
                "GoMod": "/home/myhro/go/pkg/mod/cache/download/github.com/google/go-github/v38/@v/v38.1.0.mod",
(...)
  1. Running it with -m, to list modules instead of packages, also doesn't help:
$ go list -json -m github.com/google/go-github/v38
{
        "Path": "github.com/google/go-github/v38",
        "Version": "v38.1.0",
        "Time": "2021-08-11T14:26:33Z",
        "Dir": "/home/myhro/go/pkg/mod/github.com/google/go-github/v38@v38.1.0",
        "GoMod": "/home/myhro/go/pkg/mod/cache/download/github.com/google/go-github/v38/@v/v38.1.0.mod",
        "GoVersion": "1.16"
}

The examples above were done using go version go1.21.5 linux/amd64 from sid.

I also checked if go get has any flags to resolve the root repository for a module, given that accessing https://github.com/google/go-github/v38 directly returns a 404 Not Found, but haven't find anything helpful in the CLI.

What do you think it would be a reasonable solution? Vendor the whole golang.org/x/tools module for now? Copy just the vcs package parts we are interested in?

@anthonyfok
Copy link
Member

Thank you @myhro for your help!

For testing on GitHub (where Go module is on), go mod tidy automatically picked up:

golang.org/x/tools/go/vcs v0.1.0-deprecated

so go build still works, good for dh-make-golang development/maintenance until we find a good alternative.

As for Debian packaging where GO111MODULE=off, I have used a way to sneak in Go packages, so I think I'll do that for dh-make-golang 0.7.0-1.

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants