Skip to content

Commit b4f65ca

Browse files
committed
WIP: Bzlmod part the one hundred-seventeenth
Fix @rules_proto circular dep under WORKSPACE Fixed by using `scala_proto_default_repositories` directly instead of the `scala_proto_repositories` wrapper macro. The problem was that `scala/private/macros/toolchains.bzl` had to load `scala_proto/scala_proto.bzl` to get the previous macro definition. That file defines `scala_proto_library` as a wrapper around a macro of the same name from `scala_proto/private/scala_proto.bzl`. That file, in turn, loads `@rules_proto//proto:defs.bzl`. However, `scala_toolchains` from `scala/private/macros/toolchains.bzl` is what now calls `scala_repositories`, which calls `rules_scala_setup`, which instantiates the `rules_scala` repo. This wasn't a problem under Bzlmod, but when building with `--noenable_bzlmod --enable_workspace`, this happened: ```txt ERROR: Failed to load Starlark extension '@@rules_proto//proto:repositories.bzl'. Cycle in the workspace file detected. This indicates that a repository is used prior to being defined. The following chain of repository dependencies lead to the missing definition. - @@rules_proto This could either mean you have to add the '@@rules_proto' repository with a statement like `http_archive` in your WORKSPACE file (note that transitive dependencies are not added automatically), or move an existing definition earlier in your WORKSPACE file. ERROR: Error computing the main repository mapping: cycles detected during computation of main repo mapping ```
1 parent b6a1a59 commit b4f65ca

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

scala/private/macros/toolchains.bzl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ load(
1010
"scalafmt_repositories",
1111
)
1212
load("//scala:scala_cross_version.bzl", "default_maven_server_urls")
13-
load("//scala_proto:scala_proto.bzl", "scala_proto_repositories")
13+
load(
14+
"//scala_proto/default:repositories.bzl",
15+
"scala_proto_default_repositories",
16+
)
1417
load("//scalatest:scalatest.bzl", "scalatest_repositories")
1518
load("//specs2:specs2_junit.bzl", "specs2_junit_repositories")
1619
load("//twitter_scrooge:twitter_scrooge.bzl", _scrooge = "twitter_scrooge")
@@ -131,7 +134,7 @@ def scala_toolchains(
131134
)
132135
if scala_proto:
133136
num_toolchains += 1
134-
scala_proto_repositories(
137+
scala_proto_default_repositories(
135138
maven_servers = maven_servers,
136139
scala_version = scala_version,
137140
overriden_artifacts = overridden_artifacts,

0 commit comments

Comments
 (0)