-
Notifications
You must be signed in to change notification settings - Fork 181
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
run_binary
will put files in the sandbox but then can't find them for outs
.
#554
Comments
I should also note that the same thing happens if using a # my_shell_script.sh
echo " Writing to $1" >&2
echo "Hello world" > "$1" sh_binary(
name = "my_shell_script",
srcs = ["my_shell_script.sh"],
)
run_binary(
name = "run_my_script",
tool = ":my_shell_script",
args = ["some_file.txt"],
outs = ["some_file.txt"],
) $ bazel build //:run_my_script
INFO: Analyzed target //:run_my_script (0 packages loaded, 0 targets configured).
INFO: From RunBinary some_file.txt:
Writing to some_file.txt
ERROR: /usr/local/google/home/dthor/dev/skylib-example/BUILD.bazel:14:11: output 'some_file.txt' was not created
ERROR: /usr/local/google/home/dthor/dev/skylib-example/BUILD.bazel:14:11: RunBinary some_file.txt failed: not all outputs were created or valid
Target //:run_my_script failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.126s, Critical Path: 0.02s
INFO: 2 processes: 1 internal, 1 linux-sandbox.
ERROR: Build did NOT complete successfully |
The output path of the file won't be just Could you try setting |
That's related to why I first started down this path. It seemed like OK so here's where it gets strange. Doing But doing the same thing in a different project shows that $ tail -n 11 src/pyle_xc/layout/scripts/BUILD.bazel
py_binary(
name = "doug_script",
srcs = ["doug_script.py"],
)
run_binary(
name = "run_my_script",
tool = ":doug_script",
args = ["$(execpath some_file.txt)"],
outs = ["some_file.txt"],
)
$ cat src/pyle_xc/layout/scripts/doug_script.py
import sys
import pathlib
def main():
file = pathlib.Path(sys.argv[1])
file.write_text("This is my generated data.")
print(f" Wrote to file at {file.resolve(strict=True)}", file=sys.stderr)
print(" Here's proof. The written text was:", file=sys.stderr)
print(f" {file.read_text()}", file=sys.stderr)
if __name__ == "__main__":
main()
$ bazel clean --async; bazel --ignore_all_rc_files build //src/pyle_xc/layout/scripts:run_my_script --sandbox_debug
...
INFO: From RunBinary src/pyle_xc/layout/scripts/some_file.txt:
Wrote to file at /usr/local/google/home/dthor/.cache/bazel/_bazel_dthor/dfb34a4360d7e3628ef90718c12cf15a/sandbox/linux-sandbox/15/execroot/_main/$(execpath some_file.txt)
Here's proof. The written text was:
This is my generated data.
ERROR: /usr/local/google/home/dthor/dev/pyle3-xc/src/pyle_xc/layout/scripts/BUILD.bazel:409:11: output 'src/pyle_xc/layout/scripts/some_file.txt' was not created
ERROR: /usr/local/google/home/dthor/dev/pyle3-xc/src/pyle_xc/layout/scripts/BUILD.bazel:409:11: RunBinary src/pyle_xc/layout/scripts/some_file.txt failed: not all outputs were created or valid
Target //src/pyle_xc/layout/scripts:run_my_script failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.608s, Critical Path: 0.60s
INFO: 6 processes: 5 internal, 1 linux-sandbox.
ERROR: Build did NOT complete successfully
$ tree -L 2 ~/.cache/bazel/_bazel_dthor/dfb34a4360d7e3628ef90718c12cf15a/sandbox/linux-sandbox/15/execroot/_main/
/usr/local/google/home/dthor/.cache/bazel/_bazel_dthor/dfb34a4360d7e3628ef90718c12cf15a/sandbox/linux-sandbox/15/execroot/_main/
├── $(execpath some_file.txt)
├── bazel-out
│ ├── k8-fastbuild
│ └── k8-opt-exec-ST-d57f47055a04
└── src
└── pyle_xc You'll also notice that I used Thanks for letting me rubber duck. |
Summary
run_binary
generates files in the sandbox directory but cannot find them when trying to set theouts
values.So it seems like we can't use
run_binary
as a source of files/data for other targets. Is this expected?Steps to Reproduce
Create these files:
And, if you're using Bazelisk, a
.bazelversion
file with:Then call:
Expected Result
The
run_binary
target should be able to use the file generated bypy_binary
.Actual Result
Bazel errors out, saying that the output file was not created.
The text was updated successfully, but these errors were encountered: