~sircmpwn/sr.ht-discuss

2 2

Fix `go mod vendor` error to help with rpmbuild on openSUSE Open Build System

Details
Message ID
<1a597334-6498-4a94-8067-486e1cdfd132@app.fastmail.com>
DKIM signature
missing
Download raw message
Hello!

I package and maintain a series of sr.ht RPM packages on openSUSE: https://build.opensuse.org/project/show/home:nuklly:srht. With these packages, I am able to self-host my own sr.ht instance.

However, there is one issue with respect to packaging. Since openSUSE RPM build environment does not have Internet access, I have to run `go mod vendor` to first package the vendor packages. However, when I run `go mod vendor` in meta.sr.ht, there is error:

```
git.sr.ht/~sircmpwn/meta.sr.ht/api imports
	git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/api: no required module provides package git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/api; to add it:
	go get git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/api
```

Currently I simply submit prebuilt binaries to workaround this issue, but I sincerely hope to fix this problem so that I can build the packages on openSUSE Open Build System.

Is there a way that I can fix this issue with `go mod vendor` command on meta.sr.ht and git.sr.ht?

Best,
Xu

--
Xu Zhao
i@xuzhao.net
Details
Message ID
<CXRPZROZJPIA.3HBSF6R9731ML@maolood.com>
In-Reply-To
<1a597334-6498-4a94-8067-486e1cdfd132@app.fastmail.com> (view parent)
DKIM signature
missing
Download raw message
On Wed Dec 13, 2023 at 9:46 PM EST, Xu Zhao wrote:
> I package and maintain a series of sr.ht RPM packages on openSUSE: https://build.opensuse.org/project/show/home:nuklly:srht. With these packages, I am able to self-host my own sr.ht instance.
>
> However, there is one issue with respect to packaging. Since openSUSE RPM build environment does not have Internet access, I have to run `go mod vendor` to first package the vendor packages. However, when I run `go mod vendor` in meta.sr.ht, there is error:
>
> ```
> git.sr.ht/~sircmpwn/meta.sr.ht/api imports
> 	git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/api: no required module provides package git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/api; to add it:
> 	go get git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/api
> ```

The reason for this error is because api/graph/api is generated with gqlgen.
Unlike other Go projects, the generated code is not stored in the repository and
must be generated at the time of building. This was done so that emailed patches
can omit the diffs for the generated files.

You can try running 'go mod vendor -e' to ignore the error. Then make sure
to run 'make api' to generate the code and build (this can probably be done
offline).
Details
Message ID
<bb32103f-83f6-4902-b419-5ad34e210837@app.fastmail.com>
In-Reply-To
<CXRPZROZJPIA.3HBSF6R9731ML@maolood.com> (view parent)
DKIM signature
missing
Download raw message
Sorry for the late reply. I have tried to use `go mod vendor -e`, but when I run `make api` in the build environment, it shows the following error:

```
cd api && go generate ./loaders
cd api && go generate ./graph
# github.com/urfave/cli/v2
../../vendor/github.com/urfave/cli/v2/sliceflag.go:15:12: type parameter requires go1.18 or later (-lang was set to go1.16; check go.mod)
../../vendor/github.com/urfave/cli/v2/sliceflag.go:15:29: type instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
../../vendor/github.com/urfave/cli/v2/sliceflag.go:15:44: undeclared name: any (requires version go1.18 or later)
../../vendor/github.com/urfave/cli/v2/sliceflag.go:25:18: type parameter requires go1.18 or later (-lang was set to go1.16; check go.mod)
../../vendor/github.com/urfave/cli/v2/sliceflag.go:25:20: undeclared name: any (requires version go1.18 or later)
../../vendor/github.com/urfave/cli/v2/sliceflag.go:44:29: type instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
../../vendor/github.com/urfave/cli/v2/sliceflag.go:48:30: type instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
../../vendor/github.com/urfave/cli/v2/sliceflag.go:52:28: type instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
../../vendor/github.com/urfave/cli/v2/sliceflag.go:56:26: type instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
../../vendor/github.com/urfave/cli/v2/sliceflag.go:215:24: type parameter requires go1.18 or later (-lang was set to go1.16; check go.mod)
../../vendor/github.com/urfave/cli/v2/sliceflag.go:56:26: too many errors
graph/generate.go:10: running "go": exit status 2
```

I am wondering if this is fixable by tweaking the vendoring config?

Best,
Xu

--
Xu Zhao
i@xuzhao.net

On Mon, Dec 18, 2023, at 2:52 PM, Adnan Maolood wrote:
> On Wed Dec 13, 2023 at 9:46 PM EST, Xu Zhao wrote:
>> I package and maintain a series of sr.ht RPM packages on openSUSE: https://build.opensuse.org/project/show/home:nuklly:srht. With these packages, I am able to self-host my own sr.ht instance.
>>
>> However, there is one issue with respect to packaging. Since openSUSE RPM build environment does not have Internet access, I have to run `go mod vendor` to first package the vendor packages. However, when I run `go mod vendor` in meta.sr.ht, there is error:
>>
>> ```
>> git.sr.ht/~sircmpwn/meta.sr.ht/api imports
>> 	git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/api: no required module provides package git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/api; to add it:
>> 	go get git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/api
>> ```
>
> The reason for this error is because api/graph/api is generated with gqlgen.
> Unlike other Go projects, the generated code is not stored in the repository and
> must be generated at the time of building. This was done so that emailed patches
> can omit the diffs for the generated files.
>
> You can try running 'go mod vendor -e' to ignore the error. Then make sure
> to run 'make api' to generate the code and build (this can probably be done
> offline).
Reply to thread Export thread (mbox)