-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Closed
Labels
P2We'll consider working on this in future. (Assignee optional)We'll consider working on this in future. (Assignee optional)category: misc > misctype: bug
Milestone
Description
$(location a_tool) in the cmd of a genrule doesn't add a leading ./ if the tool is in the same package, which means it doesn't work. Whether a_tool is a target or a source file doesn't seem to matter.
Example BUILD (test_tool is an empty shell script):
genrule(
name = 'my_genrule',
tools = [
'test_tool',
],
outs = [
'test_output',
],
cmd = '$(location test_tool) > $(location test_output)',
)
I end up with this error:
$ bazel build ... --verbose_failures
INFO: Found 1 target...
INFO: From Executing genrule //:my_genrule:
/bin/bash: test_tool: command not found
ERROR: /tmp/tool_test_workspace/BUILD:1:1: Executing genrule //:my_genrule failed: bash failed: error executing command
(cd /home/brian/.cache/bazel/_bazel_brian/421f2e8b7d7f6adfe83f902fa91a62f0/tool_test_workspace && \
exec env - \
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games \
/bin/bash -c 'source tools/genrule/genrule-setup.sh; test_tool > bazel-out/local_linux-fastbuild/genfiles/test_output'): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 127: bash failed: error executing command
(cd /home/brian/.cache/bazel/_bazel_brian/421f2e8b7d7f6adfe83f902fa91a62f0/tool_test_workspace && \
exec env - \
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games \
/bin/bash -c 'source tools/genrule/genrule-setup.sh; test_tool > bazel-out/local_linux-fastbuild/genfiles/test_output'): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 127.
Target //:my_genrule failed to build
INFO: Elapsed time: 0.096s, Critical Path: 0.01s
Moving the tool to another folder (whether that's another package or not) fixes this example.
Metadata
Metadata
Assignees
Labels
P2We'll consider working on this in future. (Assignee optional)We'll consider working on this in future. (Assignee optional)category: misc > misctype: bug