`@` and `@workspacename` considered different repositories
See original GitHub issueDescription of the problem / feature request / question:
Bazel evaluates the same Skylark file multiple times if it is loaded with a local path and an absolute path. This creates problems for rules, since everything gets defined twice. It is particularly problematic for named providers, since the duplicate definitions are neither equivalent nor compatible.
We ran into this issue when trying to migrate rules_go to use named providers. We load our .bzl files with local labels in our own repository, but repositories that depend on ours load using absolute labels, which causes errors.
Bazel should not evaluate the same .bzl file in the same repository more than once.
If possible, provide a minimal example to reproduce the problem:
Create an empty workspace with these files.
# WORKSPACE
workspace(name = "scratch")
# BUILD
load("//:def.bzl", "a")
load("@scratch//:def.bzl", "a")
# def.bzl
print("def.bzl evaluated")
a = 10
Run bazel query //...
to evaluate the files. The message is printed twice.
$ bazel query //...
____Loading package:
WARNING: /usr/local/google/home/jayconrod/Code/scratch/def.bzl:1:1: def.bzl evaluated.
WARNING: /usr/local/google/home/jayconrod/.cache/bazel/_bazel_jayconrod/1df8d8ad4cb35ee83522d81953b4d69f/external/scratch/def.bzl:1:1: def.bzl evaluated.
____Empty results
Environment info
- Operating System: Linux
- Bazel version (output of
bazel info release
): 0.5.0
cc @ianthehat
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:45 (43 by maintainers)
Top Results From Across the Web
How do I create a repository in a different workspace?
With admin access to a repository you'll be able to do everything a repository owner can do: change repository settings, update user permissions ......
Read more >Runfiles workspace directories use wrong workspace name if ...
This means that the runfiles actually have to be available under the a name, independent of any repository mappings. So Bazel should not...
Read more >Customize repository deployments - Microsoft Sentinel
There are two primary ways to customize the deployment of your repository content to Microsoft Sentinel workspaces. Each method uses different ...
Read more >Repository Workspace name from private builds - Jazz Forum
Hi, Hop do i get the RepositoryWorkspace name when I run a private build. From the properties file I get the RepositoryWorkspace uid...
Read more >Workspace Rules - Bazel
Suppose the current repository is a chat client, rooted at the directory ~/chat-app. It would like to use an SSL library which is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This issue should now be fixed at head. Please reopen the bug if it doesn’t address your use case. Note that referencing @<workspace_name> from the command line will still be treated as a separate repository.
Didn’t know that. Will do, thanks.