diff options
author | Brice <33697112+bricedp@users.noreply.github.com> | 2023-04-02 10:03:11 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-02 19:03:11 +0200 |
commit | 941602aedce63539747d57be384af999b0e72a5f (patch) | |
tree | 412fadc44df4c2b8d39df08f26f821a7aa86b7b1 /go/tools/go_bin_runner/process.go | |
parent | e558f56df9995f571e49de336c3831d407d9ff70 (diff) | |
download | bazelbuild-rules_go-941602aedce63539747d57be384af999b0e72a5f.tar.gz |
Fix use of `//go` with Bzlmod by removing dependency on `@org_golang_x_sys` (#3512)
* Fix use of `//go` by exposing `@org_golang_x_sys` when using Bzlmod
Running `bazel run //go` (or `bazel run @rules_go//go` from another module) fails when using Bzlmod because the `@org_golang_x_sys` repository is not visible. Without Bzlmod, the repository is loaded through a WORKSPACE dependency and the error does not happen.
Two-step minimal reproduction from root of this repo:
1. `touch WORKSPACE.bzlmod`
2. `bazel run --enable_bzlmod //go`
Here's the error that produces:
```shell
$ bazel run --enable_bzlmod //go
DEBUG: gazelle@0.27.0/MODULE.bazel:7:6: WARNING: The bazel_gazelle Bazel module is still highly experimental and subject to change at any time. Only use it to try out bzlmod for now.
WARNING: For repository 'com_google_protobuf', the root module requires module version protobuf@3.19.2, but got protobuf@3.19.6 in the resolved dependency graph.
ERROR: /Users/brice/Documents/Code/rules_go/go/tools/go_bin_runner/BUILD.bazel:11:11: no such package '@[unknown repo 'org_golang_x_sys' requested from @]//unix': The repository '@[unknown repo 'org_golang_x_sys' requested from @]' could not be resolved: No repository visible as '@org_golang_x_sys' from main repository and referenced by '//go/tools/go_bin_runner:go_bin_runner_lib'
ERROR: Analysis of target '//go:go' failed; build aborted:
INFO: Elapsed time: 3.043s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (45 packages loaded, 865 targets configured)
currently loading: go/platform
ERROR: Build failed. Not running target
```
Here's the point in the BUILD file where this repository is being referenced:
https://github.com/bazelbuild/rules_go/blob/e558f56df9995f571e49de336c3831d407d9ff70/go/tools/go_bin_runner/BUILD.bazel#L25
* Remove `process_unix.go` and use `process.go` for all platforms. Eliminates dependency on `@org_golang_x_sys`.
* Add Bzlmod test for //go
---------
Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
Diffstat (limited to 'go/tools/go_bin_runner/process.go')
-rw-r--r-- | go/tools/go_bin_runner/process.go | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/go/tools/go_bin_runner/process.go b/go/tools/go_bin_runner/process.go index 8b344c96..af236549 100644 --- a/go/tools/go_bin_runner/process.go +++ b/go/tools/go_bin_runner/process.go @@ -1,5 +1,3 @@ -//go:build !unix - package main import ( |