Closed adam-rocska closed 1 year ago
In hope, that it will help debugging, I'll add some more infos I found.
So, most probably the build_tools/javascript.bzl
is broken.
For debugging purposes I edited the file, and added the following debug code before ctx.actions.run
:
for src in lib[ProtoInfo].transitive_sources.to_list():
print("| src.short_path | ", src.short_path)
print("| src.path | ", src.path)
print("| src.dirname | ", src.dirname)
print("| src.basename | ", src.basename)
print("| src.root | ", src.root.path)
print("|----------------|--------------------------------")
Which produces the following output when running the js-dossier build directly :
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:19:9: | src.short_path | src/proto/dossier.proto
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:20:9: | src.path | src/proto/dossier.proto
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:21:9: | src.dirname | src/proto
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:22:9: | src.basename | dossier.proto
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:23:9: | src.root |
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:24:9: |----------------|--------------------------------
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:19:9: | src.short_path | src/proto/expression.proto
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:20:9: | src.path | src/proto/expression.proto
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:21:9: | src.dirname | src/proto
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:22:9: | src.basename | expression.proto
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:23:9: | src.root |
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:24:9: |----------------|--------------------------------
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:19:9: | src.short_path | src/proto/state.proto
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:20:9: | src.path | src/proto/state.proto
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:21:9: | src.dirname | src/proto
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:22:9: | src.basename | state.proto
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:23:9: | src.root |
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:24:9: |----------------|--------------------------------
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:19:9: | src.short_path | third_party/webutil/html/types/proto/_virtual_imports/proto/webutil/html/types/proto/html.proto
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:20:9: | src.path | bazel-out/darwin-fastbuild/bin/third_party/webutil/html/types/proto/_virtual_imports/proto/webutil/html/types/proto/html.proto
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:21:9: | src.dirname | bazel-out/darwin-fastbuild/bin/third_party/webutil/html/types/proto/_virtual_imports/proto/webutil/html/types/proto
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:22:9: | src.basename | html.proto
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:23:9: | src.root | bazel-out/darwin-fastbuild/bin
DEBUG: /Users/rocskaadam/src/adam-rocska/src/js-dossier/build_tools/javascript.bzl:24:9: |----------------|--------------------------------
And the following output when running as a dependency :
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:19:9: | src.short_path | ../adam_rocska_jsdossier/src/proto/dossier.proto
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:20:9: | src.path | external/adam_rocska_jsdossier/src/proto/dossier.proto
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:21:9: | src.dirname | external/adam_rocska_jsdossier/src/proto
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:22:9: | src.basename | dossier.proto
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:23:9: | src.root |
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:24:9: |----------------|--------------------------------
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:19:9: | src.short_path | ../adam_rocska_jsdossier/src/proto/expression.proto
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:20:9: | src.path | external/adam_rocska_jsdossier/src/proto/expression.proto
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:21:9: | src.dirname | external/adam_rocska_jsdossier/src/proto
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:22:9: | src.basename | expression.proto
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:23:9: | src.root |
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:24:9: |----------------|--------------------------------
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:19:9: | src.short_path | ../adam_rocska_jsdossier/src/proto/state.proto
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:20:9: | src.path | external/adam_rocska_jsdossier/src/proto/state.proto
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:21:9: | src.dirname | external/adam_rocska_jsdossier/src/proto
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:22:9: | src.basename | state.proto
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:23:9: | src.root |
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:24:9: |----------------|--------------------------------
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:19:9: | src.short_path | ../adam_rocska_jsdossier/third_party/webutil/html/types/proto/_virtual_imports/proto/webutil/html/types/proto/html.proto
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:20:9: | src.path | bazel-out/host/bin/external/adam_rocska_jsdossier/third_party/webutil/html/types/proto/_virtual_imports/proto/webutil/html/types/proto/html.proto
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:21:9: | src.dirname | bazel-out/host/bin/external/adam_rocska_jsdossier/third_party/webutil/html/types/proto/_virtual_imports/proto/webutil/html/types/proto
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:22:9: | src.basename | html.proto
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:23:9: | src.root | bazel-out/host/bin
DEBUG: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/build_tools/javascript.bzl:24:9: |----------------|--------------------------------
I'm definitely not a Bazel, Skylark, etc. expert. Just a humble user. But as a layman this doesn't look good.
I get the same behavior if by experiment I change my genrule definition :
genrule(
name = "docs",
srcs = [
"@com_google_javascript_closure_library",
"@adam_rocska_jsdossier//src/java/com/github/jsdossier:dossier_deploy.jar"
],
outs = ["asd"],
cmd = "$(locations @adam_rocska_jsdossier//src/java/com/github/jsdossier:dossier_deploy.jar)"
)
console out :
ERROR: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/src/proto/BUILD:10:1: Generating <generated file external/adam_rocska_jsdossier/src/proto/js_proto.js> failed (Exit 1) sandbox-exec failed: error executing command
(cd /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/sandbox/darwin-sandbox/55/execroot/__main__ && \
exec env - \
TMPDIR=/var/folders/r1/5_y8gt9931l0084_1wxg8mw40000gn/T/ \
/usr/bin/sandbox-exec -f /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/sandbox/darwin-sandbox/55/sandbox.sb /var/tmp/_bazel_rocskaadam/install/033b3dbfe258c4bd4b40d8a507bad31d/_embedded_binaries/process-wrapper '--timeout=0' '--kill_delay=15' bazel-out/host/bin/external/com_google_protobuf/protoc '--js_out=binary,error_on_name_conflict,library=js_proto:bazel-out/darwin-fastbuild/bin/external/adam_rocska_jsdossier/src/proto' --descriptor_set_in bazel-out/darwin-fastbuild/bin/external/adam_rocska_jsdossier/third_party/webutil/html/types/proto/proto-descriptor-set.proto.bin:bazel-out/darwin-fastbuild/bin/external/adam_rocska_jsdossier/src/proto/proto-descriptor-set.proto.bin ../adam_rocska_jsdossier/src/proto/dossier.proto ../adam_rocska_jsdossier/src/proto/expression.proto ../adam_rocska_jsdossier/src/proto/state.proto)
../adam_rocska_jsdossier/src/proto/dossier.proto: No such file or directory
Target //:docs failed to build
ERROR: /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/external/adam_rocska_jsdossier/src/java/com/github/jsdossier/BUILD:1:1 Generating <generated file external/adam_rocska_jsdossier/src/proto/js_proto.js> failed (Exit 1) sandbox-exec failed: error executing command
(cd /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/sandbox/darwin-sandbox/55/execroot/__main__ && \
exec env - \
TMPDIR=/var/folders/r1/5_y8gt9931l0084_1wxg8mw40000gn/T/ \
/usr/bin/sandbox-exec -f /private/var/tmp/_bazel_rocskaadam/aa3aa7e1d2c5ae4510d2a170d237dd00/sandbox/darwin-sandbox/55/sandbox.sb /var/tmp/_bazel_rocskaadam/install/033b3dbfe258c4bd4b40d8a507bad31d/_embedded_binaries/process-wrapper '--timeout=0' '--kill_delay=15' bazel-out/host/bin/external/com_google_protobuf/protoc '--js_out=binary,error_on_name_conflict,library=js_proto:bazel-out/darwin-fastbuild/bin/external/adam_rocska_jsdossier/src/proto' --descriptor_set_in bazel-out/darwin-fastbuild/bin/external/adam_rocska_jsdossier/third_party/webutil/html/types/proto/proto-descriptor-set.proto.bin:bazel-out/darwin-fastbuild/bin/external/adam_rocska_jsdossier/src/proto/proto-descriptor-set.proto.bin ../adam_rocska_jsdossier/src/proto/dossier.proto ../adam_rocska_jsdossier/src/proto/expression.proto ../adam_rocska_jsdossier/src/proto/state.proto)
Maybe I'm getting closer to the solution, maybe not, but I'll leave this link here, in case it'd be helpful : https://stackoverflow.com/questions/55796252/how-to-write-bazel-rules-that-work-with-external-repositories
Now I give up for a while. It seems like these could be related :
I'll attempt to fall back to using an old version of js-dossier on your repo, that was published as a jar, and revisit this problem later.
I would love to fix it myself, but I just couldn't. Spent a few days on it with no result (but at least I learned a lot about the internals of Bazel, and its surroundings).
Issue Summary
Hi!
I tried to integrate js-dossier as a dependency to generate some nice docs for the project. The plan which by my opinion should work is to load the dependencies of js-dossier; load it as an
http_archive
, and use//src/java/com/github/jsdossier:dossier
as a genrule tool.I've been tinkering with a fork in my workspace so far, to expose
//src/java/com/github/jsdossier:dossier
as public, and to make js-dossier's dependencies easily loadable using a customdossier_repositories()
call (parameterized, as it seems to be a best practice by observation).Issue Details
Steps to reproduce
@my_local_dependency_reference//src/java/com/github/jsdossier:dossier
as agenrule
toolMy debug purpose genrule definition
I know this genrule as it is wouldn't generate the docs, but I fail to even refer to the dossier jar, as it break while it loads.
Assumed main / root error message
../adam_rocska_jsdossier/src/proto/dossier.proto: No such file or directory
Output Log