bazel repository as external dependency not being build properly

1,757 views
Skip to first unread message

arpit...@gmail.com

unread,
Jan 27, 2017, 12:40:19 AM1/27/17
to bazel-discuss
I get following error while trying to use bazel repository as external dependency

ERROR: ~/.cache/bazel/_bazel_noone/ae6e9d00e8c783d8279db324d79ccc60/external/org_deepmind_lab/BUILD:432:1: no such package '@zlib_archive//': error loading package 'external': The repository named 'zlib_archive' could not be resolved and referenced by '@org_deepmind_lab//:bspc'.
ERROR: Analysis of target '//:random_agent' failed; build aborted.
INFO: Elapsed time: 13.452s

`
$tree

my-project
├── BUILD
├── python.BUILD
├── random_agent.py
└── WORKSPACE

0 directories, 4 files

$cat WORKSPACE

workspace(name = "maze_a3c")

new_local_repository(
name = "python_system",
build_file = "python.BUILD",
path = "/usr",
)

git_repository(
name = "org_deepmind_lab",
remote = "https://github.com/deepmind/lab.git",
commit = "9af8f87376c3418dd40ade46465d677c0b96f39e"



$cat BUILD

py_binary(
name = "random_agent",
srcs = ["random_agent.py"],
data = ["@org_deepmind_lab//:deepmind_lab.so"],
main = "random_agent.py",

`

Kindly suggest what is the correct way to add bazel repository as external dependency and also correctly build it.

Justine Tunney

unread,
Jan 27, 2017, 1:30:28 AM1/27/17
to arpit...@gmail.com, bazel-discuss
Try copying the stuff from the DeepMind Lab WORKSPACE file into your WORKSPACE file.

Also consider asking the DeepMind team to add a repositories.bzl file like this.

Lastly, I recommend against using git_repository(). It's basically beelzebub incarnate. Highly problematic. Consider using http_archive with a GitHub tarball snapshot instead. It'll make your builds much faster, reliable, and efficient. 


--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/d30ec2e8-823c-42f3-8227-0703aa26ad44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

arpit...@gmail.com

unread,
Jan 27, 2017, 3:13:17 AM1/27/17
to bazel-discuss, arpit...@gmail.com
> To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
Thank you quick response.
In case I copy the content of the WORKSPACE of deepmind lab repo then I also would have to copy all the BUILD.* files from the deepmind lab repo as well. I think it would work. However I think it should work without duplication.
I am unsure how to use .bzl file. I think in case I use a single .bzl file for including all the repo then I would have a single handle for all the external dependencies and then I would have to replace all @<deepmind_deps>: labels in the deepmind lab repo BUILD file to loaded_label_name I use to load(":load_repo.bzl",loaded_label_name).
I have made the change regarding using .zip instead of .git . However I think it be great if it works without making a lot of changes. I think the problem is in how the name resolution works for the BUILD file in external dependencies building(deepmind_lab in my case).
Please let me know if there is something wrong in my understanding.

Justine Tunney

unread,
Jan 27, 2017, 4:45:54 AM1/27/17
to arpit...@gmail.com, bazel-discuss
There's room for improvement in how Bazel handles external dependencies. We've got some really talented people working on this. Right now it's largely up to project owners to configure things in such a way that the project is ready to go when others use it as an external dependency. The convention for doing this is basically to set up a repositories.bzl file with a foo_repositories() function, which dependent projects then call from their WORKSPACE file. That function loads up all the transitive dependencies. Here's an example of how Nomulus depends on Closure Rules.

To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/c7406d53-46b6-4b78-9878-b8cb58e029f0%40googlegroups.com.

Kristina Chodorow

unread,
Jan 27, 2017, 10:08:24 AM1/27/17
to bazel-discuss, arpit...@gmail.com
Doesn't help you now, but https://github.com/bazelbuild/bazel/issues/1943 should make this easier.  We're planning to implement this in February.

arpit...@gmail.com

unread,
Jan 27, 2017, 2:38:58 PM1/27/17
to bazel-discuss, arpit...@gmail.com
Thank you for pointing out the issue. Looking forward to this feature.
In the meanwhile I have tried to work with the suggestion of adding .bzl file in deepmind lab repo. The new repo is located at https://github.com/arpit15/lab/tree/dev.
The issue of external dependencies seems to have resolved by adding the bazel file and changing the WORKSPACE file in deepmind lab.
However now there are some problems with BUILD genrules using relative directories name for bash commands instead of labels. Please guide as how to make the directory path relative to the current package in the BUILD file for deepmind lab.
I have also tried to add filegroup label to add the whole directory but that doesn't work.
I am getting error https://gist.github.com/arpit15/c906fd30fa4afbb977e366bcbd904587

arpit...@gmail.com

unread,
Jan 27, 2017, 2:40:09 PM1/27/17
to bazel-discuss, arpit...@gmail.com
Thank you for your suggestions. I have tried to work with the suggestion of adding .bzl file in deepmind lab repo. The new repo is located at https://github.com/arpit15/lab/tree/dev.
Reply all
Reply to author
Forward
0 new messages