question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`@` and `@workspacename` considered different repositories

See original GitHub issue

Description 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:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:45 (43 by maintainers)

github_iconTop GitHub Comments

2reactions
dkelmercommented, Jul 16, 2018

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.

0reactions
ittaizcommented, Jul 20, 2020

Didn’t know that. Will do, thanks.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found