bazel-contrib / bazel-contrib/rules_go

Bazel build: No repository visible as '@rules_go'

Open
#4,460 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1.5k
Forks
760
Avg merge
1d 11h
Merged PRs (30d)
12

Description

The following bazel build error was received when trying to update from [github.com/open-policy-agent/opa](https://pkg.go.dev/github.com/open-policy-agent/opa@v0.70.0) v0.70.0 to [github.com/open-policy-agent/opa](https://pkg.go.dev/github.com/open-policy-agent/opa@v1.8.0) v1.8.0. It targets a Go Monorepo with Bazel + Gazelle + rules_go (Bzlmod enabled).

`ERROR: error loading package '@@gazelle~~go_deps~com_github_lestrrat_go_jwx_v3//jwk': Unable to find package for @@[unknown repo 'rules_go' requested from @@gazelle~~go_deps~com_github_lestrrat_go_jwx_v3 (did you mean 'rules_cc'?)]//go:def.bzl: The repository '@@[unknown repo 'rules_go' requested from @@gazelle~~go_deps~com_github_lestrrat_go_jwx_v3 (did you mean 'rules_cc'?)]' could not be resolved: No repository visible as '@rules_go' from repository '@@gazelle~~go_deps~com_github_lestrrat_go_jwx_v3'.
ERROR: /home/lukas/.cache/bazel/_bazel_lukas/900f15fa8982dac93cf1f3f7d5adf494/external/gazelle~~go_deps~com_github_open_policy_agent_opa/v1/topdown/BUILD.bazel:3:11: error loading package '@@gazelle~~go_deps~com_github_lestrrat_go_jwx_v3//jwk': Unable to find package for @@[unknown repo 'rules_go' requested from @@gazelle~~go_deps~com_github_lestrrat_go_jwx_v3 (did you mean 'rules_cc'?)]//go:def.bzl: The repository '@@[unknown repo 'rules_go' requested from @@gazelle~~go_deps~com_github_lestrrat_go_jwx_v3 (did you mean 'rules_cc'?)]' could not be resolved: No repository visible as '@rules_go' from repository '@@gazelle~~go_deps~com_github_lestrrat_go_jwx_v3'. and referenced by '@@gazelle~~go_deps~com_github_open_policy_agent_opa//v1/topdown:topdown'
ERROR: Analysis of target '//bzlmod:go_default_library' failed; build aborted: Analysis failed
INFO: Elapsed time: 2.102s, Critical Path: 0.04s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully`

A minimal example is given in [this repository](https://github.com/lschlacher/bazel-opa-bug-reproduce).

Contributor guide

Open the contributing guide

Research direction

Start with the minimal reproduction repository linked in the issue and run the failing Bazel build for the bzlmod:go_default_library target. Trace the external OPA and com_github_lestrrat_go_jwx_v3 packages mentioned in the error, focusing on why rules_go is not visible under Bzlmod. Done means the reproduction builds successfully after the OPA upgrade.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.