-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WORKSPACE allows repository redefinition #1984
Comments
Yes this is a feature and we should document it, maybe we should restrict the redinition to only repository defined by bazel too (bazel_tools, android_*, ...) |
Ok after a quick though, we should do:
|
Hello, I have a similar issue using the "bazel-deps" from https://github.com/johnynek/bazel-deps while 1) Environment
2) Steps $ git clone https://github.com/ramtej/bazel-multiworkspace-sampler.git bazel-multiworkspace-sampler/ 2.1) To build a single app works well $ cd bazel-multiworkspace-sampler/workspaces/a.app/ 2.2) To build a single app from the "profile" workspace does not work, due to the $ cd bazel-multiworkspace-sampler/profile/ b_app/3rdparty/load.bzl", line 5, in callback The native.maven_jar rules from the b_app project that resolves the external "asm" dependency With a locally patched bazel version (simply removed the allowOverride flag) the above setup works fine. But I'm not sure what this "overriding" means in detail and what are the usecases.. and how to set the flag from e.g. WORKSPACE file. Thank you. Best Regards, |
@ramtej we should not allow repository redifinition because they can create correctness issues, we allow them at the top of the WORKSPACE file only (before any |
@damienmg thank you for the feedback. I'm not sure if I got it fully. I updated the profile/WORKSPACE file as follows: local_repository( local_repository( load("@a_app//:workspace.bzl", "a_app") load("@b_app//:workspace.bzl", "b_app") Note : ../workspaces/a.app/WORKSPACE and ../workspaces/b.app/WORKSPACE contains no load() statement. The profile/WORKSPACE uses the rule "local_repository" to load targets from the sub-workspaces /a.app and /b.app. AFTER the /a.app and /b.app sub-workspaces are loaded (local_repository rule) the load() rule are used to load targets from both a.app/b.app workspace.bzl. But still the "Cannot redefine repository after any load statement in the WORKSPACE file" error message is generated. The question is now, how to load local repositories? Is there any valid sample? I used the tensorflow approach as a template for my java based project. Thank you Best regards, |
If b_app() redefine external repositories defined in a_app() then you have a repository re-definition and the |
PS: I think this is correct but you should simply have a check using |
Hello, Thank you again ! Best Regards, PS : |
Hi there! We're doing a clean up of old issues and will be closing this one. Please reopen if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so. |
this has a test, so this is apparently expected behavior,
bazel/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
Line 919 in 1b4b341
but this is really confusing, if we have a repo twice due to some error. At the very least, the error message should point to both definitions of the repository.
$ cat WORKSPACE
Succeeds if commenting out following
load("//:test.bzl", "BLA")
LUCENE_VERS = '5.5.2'
maven_jar(
name = 'lucene_misc',
artifact = 'org.apache.lucene:lucene-misc:' + LUCENE_VERS,
sha1 = '0000000000000000000000000000000000000000',
)
maven_jar(
name = 'lucene_misc',
artifact = 'org.apache.lucene:lucene-misc:' + LUCENE_VERS,
sha1 = '37bbe5a2fb429499dfbe75d750d1778881fff45d',
)
$ bazel build //...
ERROR: /usr/local/google/home/hanwen/vc/bazel-bug/WORKSPACE:12:1: Cannot redefine repository after any load statement in the WORKSPACE file (for repository 'lucene_misc').
ERROR: Error evaluating WORKSPACE file.
ERROR: package contains errors: .
ERROR: error loading package 'external': Package 'external' contains errors.
INFO: Elapsed time: 0.100s
The text was updated successfully, but these errors were encountered: