aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCameron Martin <cameronmartin123@gmail.com>2024-02-01 17:32:31 +0000
committerGitHub <noreply@github.com>2024-02-01 17:32:31 +0000
commit0f777e198309a1bc2e5e9c4e71d3e586f6c13530 (patch)
tree39d9ca00670eb99aa49f40ecc30bedae10fa0ebc
parent649b32d8607a5bfa377468e681b355b9a88ef8f0 (diff)
downloadbazelbuild-rules_rust-0f777e198309a1bc2e5e9c4e71d3e586f6c13530.tar.gz
Use canonical repo name for aspects (#2450)
Currently when running `gen_rust_project`, the aspect given to bazel has the canonical repo name but only a single `@`. This does not work with bzlmod, since it tries to resolve this using the repository mappings, and complains that the repository does not exist: ``` ERROR: Unable to find package for @@[unknown repo 'rules_rust~0.38.0' requested from @@]//rust:defs.bzl: The repository '@@[unknown repo 'rules_rust~0.38.0' requested from @@]' could not be resolved: No repository visible as '@rules_rust~0.38.0' from main repository. ERROR: Analysis of aspects '[@@[unknown repo 'rules_rust~0.38.0' requested from @@]//rust:defs.bzl%rust_analyzer_aspect] with parameters {} on //prost:prost_toolchain_impl' failed; build aborted: Unable to find package for @@[unknown repo 'rules_rust~0.38.0' requested from @@]//rust:defs.bzl: The repository '@@[unknown repo 'rules_rust~0.38.0' requested from @@]' could not be resolved: No repository visible as '@rules_rust~0.38.0' from main repository. ``` This adds an extra `@`, so that the repository in the label is of canonical form. Fixes #2449
-rw-r--r--.bazelci/presubmit.yml2
-rw-r--r--.bcr/presubmit.yml1
-rw-r--r--tools/tool_utils.bzl2
3 files changed, 4 insertions, 1 deletions
diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml
index 6281c449..8004fb1e 100644
--- a/.bazelci/presubmit.yml
+++ b/.bazelci/presubmit.yml
@@ -644,6 +644,7 @@ tasks:
working_directory: examples/bzlmod/hello_world
run_targets:
- "//third-party:vendor"
+ - "@rules_rust//tools/rust_analyzer:gen_rust_project"
test_targets:
- "//..."
macos_bzlmod_bcr:
@@ -652,6 +653,7 @@ tasks:
working_directory: examples/bzlmod/hello_world
run_targets:
- "//third-party:vendor"
+ - "@rules_rust//tools/rust_analyzer:gen_rust_project"
test_targets:
- "//..."
diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml
index d5223107..4d1810a4 100644
--- a/.bcr/presubmit.yml
+++ b/.bcr/presubmit.yml
@@ -9,5 +9,6 @@ bcr_test_module:
platform: ${{ platform }}
run_targets:
- "//third-party:vendor"
+ - "@rules_rust//tools/rust_analyzer:gen_rust_project"
test_targets:
- "//..."
diff --git a/tools/tool_utils.bzl b/tools/tool_utils.bzl
index de876b14..4ce78d80 100644
--- a/tools/tool_utils.bzl
+++ b/tools/tool_utils.bzl
@@ -12,4 +12,4 @@ def aspect_repository():
"""
if native.repository_name() == "@":
return ""
- return native.repository_name()
+ return "@" + native.repository_name()