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

Build failures when using a local go 1.21.0 SDK #3665

Closed
adam-azarchs opened this issue Aug 17, 2023 · 3 comments · Fixed by #3666
Closed

Build failures when using a local go 1.21.0 SDK #3665

adam-azarchs opened this issue Aug 17, 2023 · 3 comments · Fixed by #3666

Comments

@adam-azarchs
Copy link
Contributor

What version of rules_go are you using?

v0.41.0

What version of gazelle are you using?

v0.32.0

What version of Bazel are you using?

6.3.2

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

Linux/amd64

Any other potentially useful information about your toolchain?

Using go_host_sdk, with go 1.21.0.

What did you do?

Attempt to build with external repository dependencies (not bzlmod, though I doubt that matters here)

What did you expect to see?

Working build.

What did you see instead?

ERROR: An error occurred during the fetch of repository 'org_golang_google_grpc_cmd_protoc_gen_go_grpc':
   Traceback (most recent call last):
        File "/.../external/bazel_gazelle/internal/go_repository.bzl", line 256, column 17, in _go_repository_impl
                fail("failed to fetch %s: %s" % (ctx.name, result.stderr))
Error in fail: failed to fetch org_golang_google_grpc_cmd_protoc_gen_go_grpc: fetch_repo: google.golang.org/grpc/cmd/[email protected]: GOPROXY list is not the empty string, but contains no entries

Building with go build works fine.

A little bit of Googling around turned up golang/go#61928. I suspect the issue is that
https://github.com/bazelbuild/rules_go/blob/139ec3c5ebf86682527aa1decc09b01d17235b97/go/private/BUILD.sdk.bazel#L77-L84
is not pulling in the new go.env file from the root of the SDK directory.

Honestly I'm not sure whether I'd count this as a bug in rules_go (for not including the file) or go itself (for failing this way if the file is missing, rather than just falling back on sensible defaults like it would if the file was present but empty).

@fmeum
Copy link
Member

fmeum commented Aug 17, 2023

@sluongng submitted a fix in bazel-contrib/bazel-gazelle@adce430, which hasn't been released yet.

@adam-azarchs Based on your investigation, it looks like adding go.env to that glob would be the more reliable approach going forward. Could you submit a PR against Gazelle that reverts bazel-contrib/bazel-gazelle@adce430 and instead adds go.env to files?

@sluongng
Copy link
Contributor

I think we don't need to revert bazel-contrib/bazel-gazelle@adce430 BEFORE adding go.env. I am not against reverting it, just don't think there is a strict dependency here between the 2 changes.

Instead, I think we should add go.env first, then test around to see if bringing in go.env would have any other side effects (i.e. GOPATH, GOTOOLCHAIN, GOMODCACHE), before reverting my change.

@fmeum
Copy link
Member

fmeum commented Aug 17, 2023

Sounds good!

stewartbutler added a commit to stewartbutler/rules_nixpkgs that referenced this issue Sep 20, 2023
Go 1.21 added a requirement for a 'go.env' file. Without that file, Go
will throw an error like:
```
Error in fail: failed to fetch org_golang_google_grpc_cmd_protoc_gen_go_grpc: fetch_repo: google.golang.org/grpc/cmd/[email protected]: GOPROXY list is not the empty string, but contains no entries
```

This commit adds it to the SDK exposed by rules_nixpkgs so that it is
compatible with rules_go.

See:
- bazel-contrib/rules_go#3665
- bazel-contrib/rules_go#3666
avdv pushed a commit to stewartbutler/rules_nixpkgs that referenced this issue Nov 3, 2023
Go 1.21 added a requirement for a 'go.env' file. Without that file, Go
will throw an error like:
```
Error in fail: failed to fetch org_golang_google_grpc_cmd_protoc_gen_go_grpc: fetch_repo: google.golang.org/grpc/cmd/[email protected]: GOPROXY list is not the empty string, but contains no entries
```

This commit adds it to the SDK exposed by rules_nixpkgs so that it is
compatible with rules_go.

See:
- bazel-contrib/rules_go#3665
- bazel-contrib/rules_go#3666
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants