Skip to content

Commit

Permalink
Use canonical repo name for aspects (#2450)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cameron-martin authored Feb 1, 2024
1 parent 649b32d commit 0f777e1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
- "//..."

Expand Down
1 change: 1 addition & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ bcr_test_module:
platform: ${{ platform }}
run_targets:
- "//third-party:vendor"
- "@rules_rust//tools/rust_analyzer:gen_rust_project"
test_targets:
- "//..."
2 changes: 1 addition & 1 deletion tools/tool_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ def aspect_repository():
"""
if native.repository_name() == "@":
return ""
return native.repository_name()
return "@" + native.repository_name()

0 comments on commit 0f777e1

Please sign in to comment.