Skip to content

Commit 21e090e

Browse files
authored
Rename bazel_version repository to avoid conflict (#460)
We use a synthetic `bazel_version` repository to make the Bazel version available in more contexts (see [bazelbuild/bazel#8305][i8305]). But some other repositories do so, too, with the same repository name and a different repository structure. In particular, it is not currently possible to use `rules_rust` and certain versions of `upb` (downstream of protobuf) in the same repository, due to their definition here: https://github.com/protocolbuffers/upb/blob/c1357afb2e39df671d89eaec49033b5329f36a3e/bazel/repository_defs.bzl#L7-L10 An easy workaround is to disambiguate the name. It looks much easier to change `rules_rust` than to change `upb` and update its long chain of workspace dependencies, hence this patch. :-) See my comment on #268 for more details and a full repro: #268 (comment) [i8305]: bazelbuild/bazel#8305 Test Plan: Tested by adding the README’s workspace stanza to TensorBoard (at current master, 8d629954c251). It fails at `rules_rust = 5998baf`, but succeeds with a `local_repository` that has this patch. Also, in this repo, `git grep @bazel_version` no longer has any matches. wchargin-branch: disambiguate-bazel-version-repo wchargin-source: e712603c3a3ebc45364cc2dcc9eca341301b5197
1 parent 7b8219a commit 21e090e

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

docs/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ bzl_library(
77
name = "all_deps",
88
srcs = [
99
"@bazel_tools//tools:bzl_srcs",
10-
"@bazel_version//:def.bzl",
10+
"@io_bazel_rules_rust_bazel_version//:def.bzl",
1111
],
1212
deps = [
1313
"@bazel_skylib//:workspace",

rust/private/rustc.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ load(
2020
"C_COMPILE_ACTION_NAME",
2121
)
2222
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
23-
load("@bazel_version//:def.bzl", "BAZEL_VERSION")
23+
load("@io_bazel_rules_rust_bazel_version//:def.bzl", "BAZEL_VERSION")
2424
load("@io_bazel_rules_rust//rust:private/legacy_cc_starlark_api_shim.bzl", "get_libs_for_static_executable")
2525
load("@io_bazel_rules_rust//rust:private/utils.bzl", "get_lib_name", "relativize")
2626

workspace.bzl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,8 @@ def rust_workspace():
4141

4242
bazel_skylib_workspace()
4343

44-
bazel_version(name = "bazel_version")
44+
# Give this repository a scoped name to avoid conflicting with other
45+
# projects' similar workarounds when used in the same workspace
46+
# (issue #268#issuecomment-713920963). TODO(#462): Investigate
47+
# whether this can be entirely replaced with `native.bazel_version`.
48+
bazel_version(name = "io_bazel_rules_rust_bazel_version")

0 commit comments

Comments
 (0)